Hello,
I am learning C++ using The C++ Programming : Special Edition by Bjarne
Stroustrup. After reading some of his papers on his site, I came across a
source code file that is used to compare timings for his Wrapper template
class. In the main comment section, Mr. Stroustrup indicates that he is
using a timing method published in JOOP by Andrew Koenig. I searched for the
article, but was unable to find it. I would like to understand the timing
method used and certain features of the implementation because so far it has
eluded me. From what I have read, to measure elapsed time one would:
#include <ctime>
clock_t start = clock();
do_something();
clock_t end = clock();
double time_elapsed = double(end - start)/CLOCKS_PER_SEC;
But in the code file in a number of places a clock_t is recorded and then a
loop is run until another clock() is passed. I understand that the code is
measuring the given functions repeatedly until the results are statistically
relevant, but why clock()'s are added in many places does not make any sense
to me.
Do any of you have the article and could explain it to me, or perhaps look
at the code and explain why so many clock()'s are used?
The link is: http://www.research.att.com/~bs/wrap_code.cpp
Thank you for time, Oplec.