How to efficiently measure runtime differences
One exercise in TC ++ PL asks:
Write a function that either returns a value or outputs that value based on an argument. Measure the difference in execution time between the two.
It's a shame that he never explains how to measure such things. I'm not sure if I can write a simple counter of time, end time, or more efficient and practical?
source to share
The only dimension that ever matters is wall clock time. Don't let anyone else trick you into believing in something else. Read Lean Thinking if you don't believe it yourself.
The easiest way is to get the system time before and after startup. if that doesn't give you enough resolution, you can look into some higher resolution system timers.
If you need more information, you can use a commercial product like point tracing: http://www.jetbrains.com/profiler/
source to share