A C++ Timer Class
About:
- A simple C++ class that is useful for
timing how long it takes to run parts of a program.
- Consists of a single header file timer.h that can
be included in any code that needs to compute the execution time
of parts of a program.
- The documentation is an example timertest.C file that contains
commented examples of all of the features of the class.
Files:
- timer.h: The header file that needs to be
included in any program that uses the timer.
- timertest.C: A simple C++ program that demonstrates
all of the capabilities of the class.
- Makefile: A Makefile used to compile the
timertest.C program above.
- timer.tar: A tar archive containing all of
the above files.
Changes:
- Nov 9, 2005:
- Minor code and documentation fixes.
- September 6, 2005:
- Removed timer.C, defined all member functions as inline in timer.h.
- April 1, 2005:
- Fixed a potential initialization bug.
- March 1, 2005:
- Changed default precision to two decimal places for time values
less than an hour, and no decimal places for longer times.
- Fixed a long-standing problem in which the timer would reset
approximately every 72 minutes. However, for longer periods the
timer computes total running time, not cpu time.
- December 16, 2004:
- Modified the interface so that it is, hopefully, simpler and more logical.
- Added an ostream operator<< to make it possible to do
things like 'cout << t' where 't' is a timer object.
- All timer values are now output to four decimal places.
This appears to be two more than what is normally kept track of on
a Linux system.
- May 13, 2003: Original posted version.
Return to my projects page.