CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
11  BenchmarkGrd(const std::string &name) : m_start(std::chrono::high_resolution_clock::now()), m_name(name) {}
12 
14  std::chrono::duration<double, std::milli> diff = std::chrono::high_resolution_clock::now() - m_start;
15  edm::LogVerbatim("Geometry") << "Benchmark '" << m_name << "' took " << diff.count() << " millis\n";
16  }
17 
18 private:
19  std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
21 };
22 
23 #ifdef BENCHMARK_ON
24 #define BENCHMARK_START(X) \
25  { \
26  BenchmarkGrd(#X)
27 #define BENCHMARK_END }
28 #else
29 #define BENCHMARK_START(X)
30 #define BENCHMARK_END
31 #endif
32 
33 #endif
Log< level::Info, true > LogVerbatim
BenchmarkGrd(const std::string &name)
Definition: BenchmarkGrd.h:11
std::chrono::time_point< std::chrono::high_resolution_clock > m_start
Definition: BenchmarkGrd.h:19
std::string m_name
Definition: BenchmarkGrd.h:20