Grok  10.0.3
ChronoTimer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <chrono>
4 #include <string>
5 
6 namespace grk
7 {
8 
10 {
11  public:
12  ChronoTimer(std::string msg) : message(msg) {}
13  void start(void)
14  {
15  startTime = std::chrono::high_resolution_clock::now();
16  }
17  void finish(void)
18  {
19  auto finish = std::chrono::high_resolution_clock::now();
20  std::chrono::duration<double> elapsed = finish - startTime;
21  GRK_INFO("%s : %f ms", message.c_str(), elapsed.count() * 1000);
22  }
23 
24  private:
25  std::string message;
26  std::chrono::high_resolution_clock::time_point startTime;
27 };
28 
29 } // namespace grk
Definition: ChronoTimer.h:10
ChronoTimer(std::string msg)
Definition: ChronoTimer.h:12
void start(void)
Definition: ChronoTimer.h:13
std::chrono::high_resolution_clock::time_point startTime
Definition: ChronoTimer.h:26
std::string message
Definition: ChronoTimer.h:25
void finish(void)
Definition: ChronoTimer.h:17
Copyright (C) 2016-2022 Grok Image Compression Inc.
Definition: ICacheable.h:20
void GRK_INFO(const char *fmt,...)
Definition: logger.cpp:40