How can I check the evaluation processing time of my application. For example how many time it needs to do A, B, C, A+C, B+C, ...
Asked
Active
Viewed 444 times
0
-
Keep a set of counter variables and increment them whenever you do an operation you want to track? – millimoose Sep 18 '13 at 15:00
-
Are you actually looking to measure the time of the whole application, a part of the application, or do you want to measure how many times it does a certain thing (function or instruction)? – Mats Petersson Sep 18 '13 at 15:02
-
@Mats Petersson as you can see from my question I want to measure time for every combination of operations I am interested in. The whole working time is just combination off everything. – Mike Sep 18 '13 at 15:07
-
And what is A, B and C? Instructions or functions? – Mats Petersson Sep 18 '13 at 15:13
-
Parts of program - for example let A be the time that program spends to load a file, B - the time that program spends to apply some algorithm on the loaded file, C - the time to execute – Mike Sep 18 '13 at 15:14
3 Answers
0
You could use
gettimeofday()
and use thetimersub()
function to get the difference.You could use
clock()
and subtract the two times. Remember to #include .
-Referenced from:
How to subtract two gettimeofday instances?
http://www.cplusplus.com/forum/unices/50561/
What is the best, most accurate timer in C++?
EDIT: Another option is chrono i/o. Gives very high precision. http://howardhinnant.github.io/duration_io/chrono_io.html
-
-
another option for more resolution is chrono i/o. http://home.roadrunner.com/~hinnant/duration_io/chrono_io.html – philhan Sep 18 '13 at 19:08
-
0
If you use linux. Command 'time' can help you:
$time ./a.out
real 0m0.137s
user 0m0.001s
sys 0m0.001s

Spoonwalker Highwater
- 411
- 2
- 9
-
Then you should read this: http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line – Spoonwalker Highwater Sep 19 '13 at 02:37
0
Use QueryPerformanceCounter().
LARGE_INTEGER s, e, f;
QueryPerformanceFrequency( &f );
QueryPerformanceCounter( &s );
// TO DO: add your code here
QueryPerformanceCounter( &e );
const __int64 durationMilliseconds = ( e.QuadPart - s.QuadPart ) * 1000 / f.QuadPart;

user1764961
- 673
- 7
- 21