12 #ifndef TESTUTILS_STOPWATCH_H    13 #define TESTUTILS_STOPWATCH_H    19 #include <type_traits>     25     template <
typename Duration>
    76     typename DefaultUnit = std::chrono::duration<double>, 
    77     typename Clock = std::chrono::high_resolution_clock
    81      "DefaultUnit type is not a std::chrono::duration specialization");
   101     template <
typename Unit>
   118     template <
typename Unit = DefaultUnit_t>
   119     void setPrevious(Unit dur);
   127     template <
typename Unit = DefaultUnit_t>
   131     template <
typename Unit = DefaultUnit_t>
   135     template <
typename Unit = DefaultUnit_t>
   139     bool running() 
const;
   163     template <
typename Unit>
   167     template <
typename Unit, 
typename From>
   168     static auto durationTo(From 
const& dur);
   182     template <
typename Duration>
   183     struct isDuration: 
public std::false_type {};
   185     template <
typename Rep, 
typename Period>
   187       : 
public std::true_type
   198 template <
typename DefaultUnit, 
typename Clock>
   206 template <
typename DefaultUnit, 
typename Clock>
   207 template <
typename Unit>
   209   (Unit prev, 
bool start )
   217 template <
typename DefaultUnit, 
typename Clock>
   226 template <
typename DefaultUnit, 
typename Clock>
   235 template <
typename DefaultUnit, 
typename Clock>
   243 template <
typename DefaultUnit, 
typename Clock>
   244 template <
typename Unit>
   251 template <
typename DefaultUnit, 
typename Clock>
   252 template <
typename Unit>
   255   auto const prev = previous<Unit>();
   256   return running()? (prev + partial<Unit>()): prev;
   261 template <
typename DefaultUnit, 
typename Clock>
   262 template <
typename Unit>
   270 template <
typename DefaultUnit, 
typename Clock>
   271 template <
typename Unit>
   279 template <
typename DefaultUnit, 
typename Clock>
   285 template <
typename DefaultUnit, 
typename Clock>
   292 template <
typename DefaultUnit, 
typename Clock>
   302   template <
typename DefaultUnit, 
typename Clock>
   303   template <
typename Rep, 
typename Duration>
   305     <std::chrono::duration<Rep, Duration>>
   307     using type = std::chrono::duration<Rep, Duration>;
   311   template <
typename DefaultUnit, 
typename Clock>
   312   template <std::
intmax_t Num, std::
intmax_t Den>
   315     using type = std::chrono::duration<
   324 template <
typename DefaultUnit, 
typename Clock>
   325 template <
typename Unit, 
typename From>
   333 #endif // TESTUTILS_STOPWATCH_H bool running() const 
Returns whether the watch is tracking time right now. 
DefaultUnit DefaultUnit_t
default unit for time report 
decltype(Clock_t::now()) TimePoint_t
type to store start time 
Type trait containing whether Duration is std::chrono::duration. 
StopWatch(bool start=true)
Initializes and starts the timer. 
static auto durationTo(From const &dur)
Convert a duration into a unit (may be a ratio or a duration) 
TimePoint_t lastStart
time of the last start 
StopWatch<> StandardStopWatch
A StopWatch with default template arguments. 
DefaultUnit_t partialDur() const 
Returns partial time as a duration. 
typename DefaultUnit_t::rep ElapsedTime_t
Type representing the reported time. 
void stop()
Pauses the watch. 
ElapsedTime_t elapsed() const 
Returns the total time spent running since the last restart. 
ElapsedTime_t partial() const 
Returns the time spent running since the last resume. 
void restart()
Restarts the watch; previous time is forgotten. 
void setPrevious(Unit dur)
Changes the amount of time accumulated before this run. 
Clock Clock_t
type of clock used to extract current time 
Provides time interval measurements. 
bool isRunning
whether we are measuring time now 
ElapsedTime_t previous() const 
Returns the time accumulated before the current run. 
void resume()
Resumes the run of the watch; previous time is preserved. 
DefaultUnit_t previousTime
time accumulated from previous runs 
Trait whose type member is a std::chrono::duration type. 
typename makeDurationTrait< Unit >::type makeDuration_t
Type of std::chrono::duration type constructed from makeDurationTrait. 
static TimePoint_t now()
Returns the current time point from our clock.