15 time_t begin = time(0);
17 while (now - begin < 5) now = time(0);
21 cout <<
"Test 1:" << endl;
22 cout <<
"This test should require less than 5 sec CPU time. \n"
23 <<
"The exact amount depends strongly on the system." << endl;
24 cout <<
"The measured elapsed CPU time is: "
25 << timer.elapsedTime() <<
" sec\n" << endl;
30 const size_t NumSqrt = 1000000;
32 for (
int i=0; i<NumSqrt; i++) x = ::sqrt(
double(i));
36 cout <<
"Test 2:" << endl;
37 cout <<
"The CPU time to calculate " << NumSqrt
38 <<
" square roots is: "
39 << timer.elapsedTime() <<
" sec\n" << endl;
41 cout <<
"The total amount of CPU seconds used \n"
42 <<
"to execute this program is: ";
44 cout << totalTimer.elapsedTime() <<
" sec." << endl;