root/doc/tutorial/src/timer.cpp @ 278

Revision 278, 0.6 kB (checked in by smidl, 15 years ago)

props

  • Property svn:eol-style set to native
Line 
1#include <itpp/itbase.h>
2
3using namespace itpp;
4
5//These lines are needed for use of cout and endl
6using std::cout;
7using std::endl;
8
9int main()
10{
11  //Declare the scalars used:
12  long i, sum, N;
13
14  //Declare tt as an instance of the timer class:
15  Real_Timer tt;
16
17  //Initiate the variables:
18  N = 1000000;
19  sum = 0;
20
21  //Start and reset the timer:
22  tt.tic();
23
24  //Do some processing
25  for (i = 0; i < N; i++) {
26    sum += i;
27  }
28
29  // Print the elapsed time
30  tt.toc_print();
31
32  //Print the result of the processing:
33  cout << "The sum of all integers from 0 to " << N - 1 << " equals " << sum << endl;
34
35  //Exit program:
36  return 0;
37
38}
Note: See TracBrowser for help on using the browser.