File indexing completed on 2023-03-17 10:51:41
0001 #ifndef DETECTOR_DESCRIPTION_BENCHMARK_GRD_H
0002 #define DETECTOR_DESCRIPTION_BENCHMARK_GRD_H
0003
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006 #include <string>
0007 #include <chrono>
0008
0009 class BenchmarkGrd {
0010 public:
0011 BenchmarkGrd(const std::string &name) : m_start(std::chrono::high_resolution_clock::now()), m_name(name) {}
0012
0013 ~BenchmarkGrd() {
0014 std::chrono::duration<double, std::milli> diff = std::chrono::high_resolution_clock::now() - m_start;
0015 edm::LogVerbatim("Geometry") << "Benchmark '" << m_name << "' took " << diff.count() << " millis\n";
0016 }
0017
0018 private:
0019 std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
0020 std::string m_name;
0021 };
0022
0023 #ifdef BENCHMARK_ON
0024 #define BENCHMARK_START(X) \
0025 { \
0026 BenchmarkGrd(#X)
0027 #define BENCHMARK_END }
0028 #else
0029 #define BENCHMARK_START(X)
0030 #define BENCHMARK_END
0031 #endif
0032
0033 #endif