32 #ifndef VSMC_UTILITY_STOP_WATCH_HPP    33 #define VSMC_UTILITY_STOP_WATCH_HPP    39 #ifndef VSMC_STOP_WATCH_CLOCK_TYPE    40 #define VSMC_STOP_WATCH_CLOCK_TYPE std::chrono::high_resolution_clock    49 template <
typename WatchType>
    56         : start_(start), watch_(watch)
    75 template <
typename ClockType>
   103         start_time_ = clock_type::now();
   118         typename clock_type::time_point stop_time = clock_type::now();
   119         elapsed_ += stop_time - start_time_;
   129         elapsed_ = 
typename clock_type::duration(0);
   136         return std::chrono::duration_cast<
   137                    std::chrono::duration<double, std::nano>>(elapsed_)
   144         return std::chrono::duration_cast<
   145                    std::chrono::duration<double, std::micro>>(elapsed_)
   152         return std::chrono::duration_cast<
   153                    std::chrono::duration<double, std::milli>>(elapsed_)
   160         return std::chrono::duration_cast<
   161                    std::chrono::duration<double, std::ratio<1>>>(elapsed_)
   168         return std::chrono::duration_cast<
   169                    std::chrono::duration<double, std::ratio<60>>>(elapsed_)
   176         return std::chrono::duration_cast<
   177                    std::chrono::duration<double, std::ratio<3600>>>(elapsed_)
   182     typename clock_type::duration elapsed_;
   183     typename clock_type::time_point start_time_;
   193 #endif // VSMC_UTILITY_STOP_WATCH_HPP 
std::chrono::high_resolution_clock clock_type
 
double nanoseconds() const 
Return the accumulated elapsed time in nanoseconds. 
 
double hours() const 
Return the accumulated elapsed time in hours. 
 
void reset()
Stop and reset the elapsed time to zero. 
 
StopWatchGuard(watch_type &watch, bool start=true)
 
double minutes() const 
Return the accumulated elapsed time in minutes. 
 
StopWatch as an adapter of C++11 clock. 
 
bool stop()
Stop the watch, no effect if already stopped. 
 
double microseconds() const 
Return the accumulated elapsed time in microseconds. 
 
double milliseconds() const 
Return the accumulated elapsed time in milliseconds. 
 
bool start()
Start the watch, no effect if already started. 
 
Start and stop a StopWatch in scope (similiar to a mutex lock guard) 
 
bool running() const 
If the watch is running. 
 
double seconds() const 
Return the accumulated elapsed time in seconds.