timer - #ifndef TIMER_H # #define TIMER_H #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#ifndef TIMER_H #define TIMER_H # #include <ctime> #include <iostream> #include <iomanip> # class timer { friend std::ostream& operator<<(std::ostream& os, timer& t); public: bool running; clock_t start_clock; time_t start_time; double acc_time; double elapsed_time(); public: // 'running' is initially false. A timer needs to be explicitly started // using 'start' or 'restart' timer() : running(false), start_clock(0), start_time(0), acc_time(0) { } void start(const char* msg = 0); void restart(const char* msg = 0); void stop(const char* msg = 0); void check(const char* msg = 0); }; // class timer } //=========================================================================== // Return the total time that the timer has been in the "running" // state since it was first "started" or last "restarted". For // "short" time periods (less than an hour), the actual cpu time // used is reported instead of the elapsed time. / inline double timer::elapsed_time() { time_t acc_sec = time(0) - start_time;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

timer - #ifndef TIMER_H # #define TIMER_H #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online