diff options
author | B Stack <bgstack15@gmail.com> | 2020-07-22 16:56:03 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-07-22 16:56:03 +0000 |
commit | e5633fb1c0db91f01ab967330b76baf4ecdb0512 (patch) | |
tree | 10260e25ae905564f7978b83fc4e316670f987c6 /zen/perf.h | |
parent | Merge branch '10.25' into 'master' (diff) | |
parent | add upstream 11.0 (diff) | |
download | FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.gz FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.bz2 FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.zip |
Merge branch '11.0' into 'master'11.0
add upstream 11.0
See merge request opensource-tracking/FreeFileSync!24
Diffstat (limited to 'zen/perf.h')
-rw-r--r-- | zen/perf.h | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -21,9 +21,9 @@ /* Example: Aggregated function call time: - static zen::PerfTimer timer; - timer.resume(); - ZEN_ON_SCOPE_EXIT(timer.pause()); + static zen::PerfTimer perfTest(true); //startPaused + perfTest.resume(); + ZEN_ON_SCOPE_EXIT(perfTest.pause()); */ namespace zen @@ -41,6 +41,8 @@ namespace zen class StopWatch { public: + explicit StopWatch(bool startPaused = false) : paused_(startPaused) {} + bool isPaused() const { return paused_; } void pause() @@ -77,7 +79,7 @@ public: } private: - bool paused_ = false; + bool paused_; std::chrono::steady_clock::time_point startTime_ = std::chrono::steady_clock::now(); std::chrono::nanoseconds elapsedUntilPause_{}; //std::chrono::duration is uninitialized by default! WTF! When will this stupidity end??? }; @@ -86,10 +88,13 @@ private: class PerfTimer { public: - [[deprecated]] PerfTimer() {} + [[deprecated]] explicit PerfTimer(bool startPaused = false) : watch_(startPaused) {} ~PerfTimer() { if (!resultShown_) showResult(); } + void pause () { watch_.pause(); } + void resume() { watch_.resume(); } + void showResult() { const bool wasRunning = !watch_.isPaused(); |