diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
commit | 89621addb4a7c87d2e3f3e7462e3c690cf71de71 (patch) | |
tree | 008b5dea7624ee1eeb57ff82c45fdf1afcab3b08 /zen/perf.h | |
parent | 7.5 (diff) | |
download | FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.gz FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.bz2 FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.zip |
7.6
Diffstat (limited to 'zen/perf.h')
-rw-r--r-- | zen/perf.h | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -4,8 +4,8 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef DEBUG_PERF_HEADER_83947184145342652456 -#define DEBUG_PERF_HEADER_83947184145342652456 +#ifndef PERF_H_83947184145342652456 +#define PERF_H_83947184145342652456 #include "deprecate.h" #include "tick_count.h" @@ -17,6 +17,7 @@ #include <iostream> #endif + //############# two macros for quick performance measurements ############### #define PERF_START zen::PerfTimer perfTest; #define PERF_STOP perfTest.showResult(); @@ -30,19 +31,14 @@ public: class TimerError {}; ZEN_DEPRECATE - PerfTimer() : //throw TimerError - ticksPerSec_(ticksPerSec()), - resultShown(false), - startTime(getTicksNow()), - paused(false), - elapsedUntilPause(0) + PerfTimer() : startTime(getTicksNow()) //throw TimerError { //std::clock() - "counts CPU time in Linux GCC and wall time in VC++" - WTF!??? if (ticksPerSec_ == 0) throw TimerError(); } - ~PerfTimer() { if (!resultShown) try { showResult(); } catch (TimerError&) {} } + ~PerfTimer() { if (!resultShown) try { showResult(); } catch (TimerError&) { assert(false); } } void pause() { @@ -102,12 +98,12 @@ private: return now; } - const std::int64_t ticksPerSec_; - bool resultShown; + const std::int64_t ticksPerSec_ = ticksPerSec(); //return 0 on error + bool resultShown = false; TickVal startTime; - bool paused; - int64_t elapsedUntilPause; + bool paused = false; + int64_t elapsedUntilPause = 0; }; } -#endif //DEBUG_PERF_HEADER_83947184145342652456 +#endif //PERF_H_83947184145342652456 |