| 103 | } |
| 104 | |
| 105 | void Profiler::timerEnd(const std::string& key) |
| 106 | { |
| 107 | #ifdef PROFILER_ENABLED |
| 108 | const std::lock_guard<std::mutex> lock{sMutexProfiler}; |
| 109 | if (sProfilerTuple.count(key) > 0) |
| 110 | { |
| 111 | auto tuple = sProfilerTuple[key]; |
| 112 | // Time between init & end |
| 113 | const auto timeNs = (double)std::chrono::duration_cast<std::chrono::nanoseconds>( |
| 114 | std::chrono::high_resolution_clock::now() - std::get<2>(tuple) |
| 115 | ).count(); |
| 116 | // Accumulate averaged time |
| 117 | std::get<0>(tuple) += timeNs; |
| 118 | std::get<1>(tuple)++; |
| 119 | |
| 120 | sProfilerTuple[key] = tuple; |
| 121 | } |
| 122 | else |
| 123 | error("Profiler::timerEnd called with a non-existing key.", __LINE__, __FUNCTION__, __FILE__); |
| 124 | #else |
| 125 | UNUSED(key); |
| 126 | #endif |
| 127 | } |
| 128 | |
| 129 | void Profiler::printAveragedTimeMsOnIterationX(const std::string& key, const int line, const std::string& function, |
| 130 | const std::string& file, const unsigned long long x) |