CMS 3D CMS Logo

BenchmarkGrd.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_BENCHMARK_GRD_H
2 #define DETECTOR_DESCRIPTION_BENCHMARK_GRD_H
3 
5 
6 #include <string>
7 #include <chrono>
8 
9 class BenchmarkGrd {
10  public:
12  : m_start( std::chrono::high_resolution_clock::now()),
13  m_name( name )
14  {}
15 
17  std::chrono::duration< double, std::milli > diff = std::chrono::high_resolution_clock::now() - m_start;
18  edm::LogVerbatim("Geometry") << "Benchmark '" << m_name << "' took " << diff.count() << " millis\n";
19  }
20 
21  private:
22  std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
24 };
25 
26 #ifdef BENCHMARK_ON
27 # define BENCHMARK_START(X) {BenchmarkGrd(#X)
28 # define BENCHMARK_END }
29 #else
30 # define BENCHMARK_START(X)
31 # define BENCHMARK_END
32 #endif
33 
34 #endif
BenchmarkGrd(const std::string &name)
Definition: BenchmarkGrd.h:11
std::chrono::time_point< std::chrono::high_resolution_clock > m_start
Definition: BenchmarkGrd.h:22
std::string m_name
Definition: BenchmarkGrd.h:23