Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //mark start time
- clock_t st = clock();
- double start = cpuTime();
- //do stuff
- double sum = 0;
- for (double d=0; d<10000; d+=0.01) {
- sum += sin( d ) * cos( d );
- }
- Sleep( 2000 ); //sleep for 2 sec
- //mark end time
- double end = cpuTime();
- clock_t et = clock();
- //calc deltas
- double cpuTime = end - start;
- double elapsedTime = ((double)et - st) / CLOCKS_PER_SEC;
- //report results
- cout << "cpu time = " << cpuTime << " sec" << endl;
- cout << "elapsed time = " << elapsedTime << " sec" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement