In this example we are using the Real_Timer class to measure the execution time of a simple program. The Real_Timer class is included in the itmisc library.
using std::cout;
using std::endl;
int main()
{
Real_Timer tt;
N = 1000000;
tt.tic();
for (i = 0; i < N; i++) {
}
tt.toc_print();
cout <<
"The sum of all integers from 0 to " << N - 1 <<
" equals " <<
sum << endl;
return 0;
}
T sum(const Vec< T > &v)
Sum of all elements in the vector.
Include file for the IT++ base module.
When you run this program, the output will look something like this:
Elapsed time = 0.000797055 seconds
The sum of all integers from 0 to 999999 equals 1783293664