summaryrefslogtreecommitdiff
path: root/zen/perf.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-07-22 16:56:03 +0000
committerB Stack <bgstack15@gmail.com>2020-07-22 16:56:03 +0000
commite5633fb1c0db91f01ab967330b76baf4ecdb0512 (patch)
tree10260e25ae905564f7978b83fc4e316670f987c6 /zen/perf.h
parentMerge branch '10.25' into 'master' (diff)
parentadd upstream 11.0 (diff)
downloadFreeFileSync-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.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/zen/perf.h b/zen/perf.h
index 33005e9f..2598ea76 100644
--- a/zen/perf.h
+++ b/zen/perf.h
@@ -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();
bgstack15