From bc7c140fd5736cb6ce427bebedfdf5bf1e80c4c3 Mon Sep 17 00:00:00 2001 From: cryptocode Date: Wed, 19 Feb 2020 14:07:52 +0100 Subject: [PATCH] Move back timer comments to header --- nano/lib/timer.cpp | 28 --------------------------- nano/lib/timer.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++ nano/node/socket.hpp | 2 +- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/nano/lib/timer.cpp b/nano/lib/timer.cpp index 1ff7b630e7..d45bab4baa 100644 --- a/nano/lib/timer.cpp +++ b/nano/lib/timer.cpp @@ -66,7 +66,6 @@ desc (description_a) { } -/** Do not output if measured time is below the time units threshold in \p minimum_a */ template nano::timer & nano::timer::set_minimum (UNIT minimum_a) { @@ -74,11 +73,6 @@ nano::timer & nano::timer::set_minimum (UNIT minimum_a return *this; } -/** - * Create a child timer without starting it. - * Since the timing API needs to have low overhead, this function - * does not check if a timer with the same name already exists. - */ template nano::timer & nano::timer::child (std::string const & description_a) { @@ -86,7 +80,6 @@ nano::timer & nano::timer::child (std::string const & return children.back (); } -/** Create and start a child timer */ template nano::timer & nano::timer::start_child (std::string const & description_a) { @@ -95,7 +88,6 @@ nano::timer & nano::timer::start_child (std::string co return child_timer; } -/** Start the timer. This will assert if the timer is already started. */ template void nano::timer::start () { @@ -104,7 +96,6 @@ void nano::timer::start () begin = CLOCK::now (); } -/** Restarts the timer */ template void nano::timer::restart () { @@ -114,11 +105,6 @@ void nano::timer::restart () measurements = 0; } -/** - * Stops the timer and increases the measurement count. A timer can be started and paused - * multiple times (e.g. in a loop). - * @return duration - */ template UNIT nano::timer::pause () { @@ -126,10 +112,6 @@ UNIT nano::timer::pause () return stop (); } -/** - * Stop timer - * @return duration - */ template UNIT nano::timer::stop () { @@ -141,16 +123,12 @@ UNIT nano::timer::stop () return ticks; } -/** - * Return current units. - */ template UNIT nano::timer::value () const { return ticks; } -/** Returns the duration in UNIT since the timer was last started. */ template UNIT nano::timer::since_start () const { @@ -158,7 +136,6 @@ UNIT nano::timer::since_start () const return std::chrono::duration_cast (end - begin); } -/** Returns true if the timer was last started longer than \p duration_a units ago*/ template bool nano::timer::after_deadline (UNIT duration_a) { @@ -166,7 +143,6 @@ bool nano::timer::after_deadline (UNIT duration_a) return std::chrono::duration_cast (end - begin) > duration_a; } -/** Returns true if the timer was last started shorter than \p duration_a units ago*/ template bool nano::timer::before_deadline (UNIT duration_a) { @@ -174,7 +150,6 @@ bool nano::timer::before_deadline (UNIT duration_a) return std::chrono::duration_cast (end - begin) < duration_a; } -/** Stop timer and write measurements to \p stream_a */ template void nano::timer::stop (std::ostream & stream_a) { @@ -182,7 +157,6 @@ void nano::timer::stop (std::ostream & stream_a) print (stream_a); } -/** Stop timer and write measurements to \p output_a */ template void nano::timer::stop (std::string & output_a) { @@ -191,7 +165,6 @@ void nano::timer::stop (std::string & output_a) output_a = stream.str (); } -/** Print measurements to the \p stream_a */ template void nano::timer::print (std::ostream & stream_a) { @@ -222,7 +195,6 @@ void nano::timer::print (std::ostream & stream_a) } } -/** Returns the SI unit string */ template std::string nano::timer::unit () const { diff --git a/nano/lib/timer.hpp b/nano/lib/timer.hpp index 6335f13305..61c201d3fb 100644 --- a/nano/lib/timer.hpp +++ b/nano/lib/timer.hpp @@ -22,20 +22,66 @@ class timer timer (nano::timer_state state_a, std::string const & description_a = "timer"); timer (std::string const & description_a); timer (std::string const & description_a, timer * parent_a); + + /** Do not output if measured time is below the time units threshold in \p minimum_a */ timer & set_minimum (UNIT minimum_a); + + /** + * Create a child timer without starting it. + * Since the timing API needs to have low overhead, this function + * does not check if a timer with the same name already exists. + */ timer & child (std::string const & description_a = "child timer"); + + /** Create and start a child timer */ timer & start_child (std::string const & description_a = "child timer"); + + /** Start the timer. This will assert if the timer is already started. */ void start (); + + /** + * Restarts the timer by setting start time to current time and resetting tick count. + * This can be called in any timer state. + */ void restart (); + + /** + * Stops the timer and increases the measurement count. A timer can be started and paused + * multiple times (e.g. in a loop). + * @return duration + */ UNIT pause (); + + /** + * Stop timer. This will assert if the timer is not in a started state. + * @return duration + */ UNIT stop (); + + /** + * Return current tick count. + */ UNIT value () const; + + /** Returns the duration in UNIT since the timer was last started. */ UNIT since_start () const; + + /** Returns true if the timer was last started longer than \p duration_a units ago*/ bool after_deadline (UNIT duration_a); + + /** Returns true if the timer was last started shorter than \p duration_a units ago*/ bool before_deadline (UNIT duration_a); + + /** Stop timer and write measurements to \p stream_a */ void stop (std::ostream & stream_a); + + /** Stop timer and write measurements to \p output_a */ void stop (std::string & output_a); + + /** Print measurements to the \p stream_a */ void print (std::ostream & stream_a); + + /** Returns the SI unit string */ std::string unit () const; nano::timer_state current_state () const; diff --git a/nano/node/socket.hpp b/nano/node/socket.hpp index 30e8122be5..14a56b7227 100644 --- a/nano/node/socket.hpp +++ b/nano/node/socket.hpp @@ -13,7 +13,7 @@ namespace nano { -/** Policy to affects at which stage a buffer can be dropped */ +/** Policy to affect at which stage a buffer can be dropped */ enum class buffer_drop_policy { /** Can be dropped by bandwidth limiter (default) */