C++ Utilities
Loading...
Searching...
No Matches
utilities::stopwatch< Clock >

See the Stopwatch page for all the details. More...

#include <stopwatch.h>

Public Types

using clock_type = Clock
 The underlying clock type.

Public Member Functions

 stopwatch (const std::string &str="")
 A stopwatch can have a name to distinguish it from others you may have running.
std::string name () const
 Provides read-only access to the stopwatch's name.
std::string & name ()
 Provides read-write access to the stopwatch's name.
constexpr void reset ()
 Set/reset the stopwatch's 'zero' point & clear any measured splits.
constexpr double elapsed () const
 Get the time that has passed from the zero point to now. Units are seconds.
constexpr double click ()
 Clicks the stopwatch to create a new 'split' and returns the elapsed time in seconds.
constexpr double split () const
 Returns the split as the time in seconds that elapsed from the zero point to the last click.
constexpr double lap () const
 Returns the last 'lap' time in seconds (i.e. the time between prior 2 splits).
std::string to_string () const
 Returns a string representation of the stopwatch's elapsed time in seconds.

Detailed Description

template<typename Clock = std::chrono::high_resolution_clock>
class utilities::stopwatch< Clock >

See the Stopwatch page for all the details.