Changeset 1064 for library/doc/tutorial/src/timer.cpp
- Timestamp:
- 06/09/10 14:00:40 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/tutorial/src/timer.cpp
r477 r1064 8 8 9 9 int main() { 10 11 10 //Declare the scalars used: 11 long i, sum, N; 12 12 13 14 13 //Declare tt as an instance of the timer class: 14 Real_Timer tt; 15 15 16 17 18 16 //Initiate the variables: 17 N = 1000000; 18 sum = 0; 19 19 20 21 20 //Start and reset the timer: 21 tt.tic(); 22 22 23 24 25 26 23 //Do some processing 24 for ( i = 0; i < N; i++ ) { 25 sum += i; 26 } 27 27 28 29 28 // Print the elapsed time 29 tt.toc_print(); 30 30 31 32 31 //Print the result of the processing: 32 cout << "The sum of all integers from 0 to " << N - 1 << " equals " << sum << endl; 33 33 34 35 34 //Exit program: 35 return 0; 36 36 37 37 }