MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / Timer

Class Timer

include/util/time.h:29–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28#ifdef USE_TIMER
29class Timer {
30public:
31 typedef std::chrono::system_clock::time_point time_point;
32 typedef std::chrono::high_resolution_clock clock;
33
34 static std::unordered_map<std::string, int> occurrence;
35
36 const char *prompt;
37 int log_frequency;
38 time_point start;
39
40 Timer(const char *_prompt, int _log_frequency = 1)
41 : prompt(_prompt), log_frequency(_log_frequency), start(clock::now()) {
42 if (occurrence.find(prompt) == occurrence.end())
43 occurrence[prompt] = 0;
44 }
45
46 ~Timer() {
47 time_point end = clock::now();
48 LOG_IF(INFO, ++occurrence[prompt] == 1) << prompt << ": " << (end - start).count() / 1.0e6 << " ms";
49 occurrence[prompt] %= log_frequency;
50 }
51};
52
53std::unordered_map<std::string, int> Timer::occurrence;
54#else

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected