summaryrefslogtreecommitdiff
path: root/zen/perf.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-07-22 11:37:03 -0400
committerB Stack <bgstack15@gmail.com>2020-07-22 11:37:03 -0400
commitc95b3937fef3e2c63768f1b3b1dc2c898f23d91d (patch)
tree10260e25ae905564f7978b83fc4e316670f987c6 /zen/perf.h
parentMerge branch '10.25' into 'master' (diff)
downloadFreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.tar.gz
FreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.tar.bz2
FreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.zip
add upstream 11.0
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