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

Revision 477, 0.6 kB (checked in by mido, 15 years ago)

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

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