root/library/doc/tutorial/src/timer.cpp
@
1064
Revision 1064, 0.7 kB (checked in by mido, 14 years ago) | |
---|---|
|
Rev | Line | |
---|---|---|
[261] | 1 | #include <itpp/itbase.h> |
2 | ||
3 | using namespace itpp; | |
4 | ||
5 | //These lines are needed for use of cout and endl | |
6 | using std::cout; | |
7 | using std::endl; | |
8 | ||
[477] | 9 | int main() { |
[1064] | 10 | //Declare the scalars used: |
11 | long i, sum, N; | |
[261] | 12 | |
[1064] | 13 | //Declare tt as an instance of the timer class: |
14 | Real_Timer tt; | |
[261] | 15 | |
[1064] | 16 | //Initiate the variables: |
17 | N = 1000000; | |
18 | sum = 0; | |
[261] | 19 | |
[1064] | 20 | //Start and reset the timer: |
21 | tt.tic(); | |
[261] | 22 | |
[1064] | 23 | //Do some processing |
24 | for ( i = 0; i < N; i++ ) { | |
25 | sum += i; | |
26 | } | |
[261] | 27 | |
[1064] | 28 | // Print the elapsed time |
29 | tt.toc_print(); | |
[261] | 30 | |
[1064] | 31 | //Print the result of the processing: |
32 | cout << "The sum of all integers from 0 to " << N - 1 << " equals " << sum << endl; | |
[261] | 33 | |
[1064] | 34 | //Exit program: |
35 | return 0; | |
[261] | 36 | |
37 | } |
Note: See TracBrowser
for help on using the browser.