From b930b84ec6416f08d3cded0b94aebe17e0e17230 Mon Sep 17 00:00:00 2001 From: cryptocode Date: Tue, 5 Feb 2019 01:08:21 +0100 Subject: [PATCH] Configurable timer clock type (#1699) --- nano/lib/timer.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nano/lib/timer.hpp b/nano/lib/timer.hpp index f52fb8b4d..ff57e9d72 100644 --- a/nano/lib/timer.hpp +++ b/nano/lib/timer.hpp @@ -16,7 +16,7 @@ enum class timer_state }; /** Timer utility with nesting support */ -template +template class timer { public: @@ -73,14 +73,14 @@ public: { assert (state == nano::timer_state::stopped); state = nano::timer_state::started; - begin = std::chrono::high_resolution_clock::now (); + begin = CLOCK::now (); } /** Restarts the timer */ void restart () { state = nano::timer_state::started; - begin = std::chrono::high_resolution_clock::now (); + begin = CLOCK::now (); ticks = UNIT::zero (); measurements = 0; } @@ -105,7 +105,7 @@ public: assert (state == nano::timer_state::started); state = nano::timer_state::stopped; - auto end = std::chrono::high_resolution_clock::now (); + auto end = CLOCK::now (); ticks += std::chrono::duration_cast (end - begin); return ticks; } @@ -121,21 +121,21 @@ public: /** Returns the duration in UNIT since the timer was last started. */ UNIT since_start () { - auto end = std::chrono::high_resolution_clock::now (); + auto end = CLOCK::now (); return std::chrono::duration_cast (end - begin); } /** Returns true if the timer was last started longer than \p duration_a units ago*/ bool after_deadline (UNIT duration_a) { - auto end = std::chrono::high_resolution_clock::now (); + auto end = CLOCK::now (); return std::chrono::duration_cast (end - begin) > duration_a; } /** Returns true if the timer was last started shorter than \p duration_a units ago*/ bool before_deadline (UNIT duration_a) { - auto end = std::chrono::high_resolution_clock::now (); + auto end = CLOCK::now (); return std::chrono::duration_cast (end - begin) < duration_a; } @@ -200,7 +200,7 @@ private: std::vector children; nano::timer_state state{ nano::timer_state::stopped }; std::string desc; - std::chrono::time_point begin; + std::chrono::time_point begin; UNIT ticks{ 0 }; UNIT minimum{ UNIT::zero () }; unsigned measurements{ 0 };