diff options
Diffstat (limited to 'src/yapf/yapf.hpp')
-rw-r--r-- | src/yapf/yapf.hpp | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/yapf/yapf.hpp b/src/yapf/yapf.hpp index 60d404804..5b5a27c0e 100644 --- a/src/yapf/yapf.hpp +++ b/src/yapf/yapf.hpp @@ -41,21 +41,53 @@ struct CPerformanceTimer CPerformanceTimer() : m_start(0), m_acc(0) {} - FORCEINLINE void Start() {m_start = QueryTime();} - FORCEINLINE void Stop() {m_acc += QueryTime() - m_start;} - FORCEINLINE int Get(int64 coef) {return (int)(m_acc * coef / QueryFrequency());} - - FORCEINLINE int64 QueryTime() {return ottd_rdtsc();} - FORCEINLINE int64 QueryFrequency() {return ((int64)2200 * 1000000);} + FORCEINLINE void Start() + { + m_start = QueryTime(); + } + + FORCEINLINE void Stop() + { + m_acc += QueryTime() - m_start; + } + + FORCEINLINE int Get(int64 coef) + { + return (int)(m_acc * coef / QueryFrequency()); + } + + FORCEINLINE int64 QueryTime() + { + return ottd_rdtsc(); + } + + FORCEINLINE int64 QueryFrequency() + { + return ((int64)2200 * 1000000); + } }; struct CPerfStartReal { CPerformanceTimer *m_pperf; - FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf) {if (m_pperf != NULL) m_pperf->Start();} - FORCEINLINE ~CPerfStartReal() {Stop();} - FORCEINLINE void Stop() {if (m_pperf != NULL) {m_pperf->Stop(); m_pperf = NULL;}} + FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf) + { + if (m_pperf != NULL) m_pperf->Start(); + } + + FORCEINLINE ~CPerfStartReal() + { + Stop(); + } + + FORCEINLINE void Stop() + { + if (m_pperf != NULL) { + m_pperf->Stop(); + m_pperf = NULL; + } + } }; struct CPerfStartFake |