8 #ifndef Sawyer_Stopwatch_H
9 #define Sawyer_Stopwatch_H
11 #include <Sawyer/Sawyer.h>
13 #ifdef SAWYER_HAVE_BOOST_CHRONO
14 # include <boost/chrono/duration.hpp>
15 # include <boost/chrono/system_clocks.hpp>
43 #ifdef SAWYER_HAVE_BOOST_CHRONO
44 typedef boost::chrono::high_resolution_clock::time_point TimePoint;
45 typedef boost::chrono::duration<double> Duration;
47 typedef double TimePoint;
48 typedef double Duration;
52 #include <Sawyer/WarningsOff.h>
53 mutable TimePoint begin_;
54 mutable Duration elapsed_;
56 #include <Sawyer/WarningsRestore.h>
62 explicit Stopwatch(
bool start=
true): elapsed_(0), running_(false) {
63 start && this->start();
69 double clear(
double value=0.0);
78 double start(
double value);
91 double stop(
bool clear=
false);
97 double report(
bool clear=
false)
const;
105 std::string toString()
const;
108 static std::string toString(
double seconds);
112 SAWYER_EXPORT std::ostream& operator<<(std::ostream&,
const Stopwatch&);