root/library/doc/tutorial/src/timer.cpp @ 1211

Revision 1064, 0.7 kB (checked in by mido, 14 years ago)

astyle applied all over the library

  • 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    //Declare the scalars used:
11    long i, sum, N;
12
13    //Declare tt as an instance of the timer class:
14    Real_Timer tt;
15
16    //Initiate the variables:
17    N = 1000000;
18    sum = 0;
19
20    //Start and reset the timer:
21    tt.tic();
22
23    //Do some processing
24    for ( i = 0; i < N; i++ ) {
25        sum += i;
26    }
27
28    // Print the elapsed time
29    tt.toc_print();
30
31    //Print the result of the processing:
32    cout << "The sum of all integers from 0 to " << N - 1 << " equals " << sum << endl;
33
34    //Exit program:
35    return 0;
36
37}
Note: See TracBrowser for help on using the browser.