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()
{
long i, sum, N;
N = 1000000;
sum = 0;
for (i = 0; i < N; i++) {
sum += i;
}
cout << "The sum of all integers from 0 to " << N - 1 << " equals " << sum << endl;
return 0;
}
void toc_print(void)
Prints the elapsed time since last tic()
void tic(void)
Resets the timer and starts it.
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