311, Introduction to Systems Programming
Introduction to Unix
It's the elapsed time that matters. You should consider how long
to wait (wall-clock time) or how much time the processor spent
executing the program (CPU time, further subdivided into user time and
- When is wall-clock time not a reliable measurement of
the time it takes to run a program?
Wall clock time is calculated by making two calls to some function like
gettimeofday(), and then subtracting.
The clocks themselves are usually
pretty good, so we need to look at reproducibility - If you repeat the
program, do you get the same time? There is always a small amount
of variation. More importantly, processes compete with each other
for use of the processor, and some other process may have run in
addition to the one you are trying to measure. You could also
cores, and a program that takes advantage of that, so the wall-clock
time on a two-core system
is not reproducible on
a one-core system.
You're on your own here ... the last one is either annoying or
tricky, depending on whether you look at a function like
- The current time and date is provided from the operating system
a 32-bit integer counting the number of seconds since "the Epoch",
midnight on 1 Jan. 1970, Coordinated Universal Time. (See the
- When does this time "roll over"?
- What are the equivalent starting times for Windows and Mac OS X?
or file formats. For Excel, see http://support.microsoft.com/kb/q180162/
although that may be more than you wanted to know.
Last revised, 9 Jan. 2012