diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-05 21:04:36 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-05 21:04:36 +0800 |
| commit | ad1ba6795040d569d3b4857fcd39cdb6a7ed1c21 (patch) | |
| tree | ee0ee976bddc9e27db0da75ad2a78ff778206fcd /src/base/log/Logger.cpp | |
| parent | f5c801de04f423269d9cefa3d725b52b87c7a0b9 (diff) | |
| download | cru-ad1ba6795040d569d3b4857fcd39cdb6a7ed1c21.tar.gz cru-ad1ba6795040d569d3b4857fcd39cdb6a7ed1c21.tar.bz2 cru-ad1ba6795040d569d3b4857fcd39cdb6a7ed1c21.zip | |
Add Measure time log. Clean up OpenGL renderer.
Diffstat (limited to 'src/base/log/Logger.cpp')
| -rw-r--r-- | src/base/log/Logger.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/base/log/Logger.cpp b/src/base/log/Logger.cpp index d75e006b..58fa6220 100644 --- a/src/base/log/Logger.cpp +++ b/src/base/log/Logger.cpp @@ -3,6 +3,7 @@ #include "cru/base/log/StdioLogTarget.h" #include <algorithm> +#include <chrono> #include <condition_variable> #include <cstdlib> #include <ctime> @@ -167,4 +168,16 @@ void Logger::LogThreadRun() { if (stop) return; } } + +Guard MeasureTimeAndLog(std::string_view tag, std::string_view name) { + CruLogDebug(std::string(tag), "Start measure {}.", name); + auto start = std::chrono::high_resolution_clock::now(); + + return Guard([tag = std::string(tag), name = std::string(name), start] { + auto end = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast<std::chrono::microseconds>(end - start); + CruLogDebug(tag, "End measure {}, time {} us.", name, duration.count()); + }); +} } // namespace cru::log |
