G
gautamcool88
I want to measure the execution time of a function, which is in the
order of microseconds. The approach I am using right now is to call
the function a sufficient number of times so that the cumulative time
is measurable, then divide the cumulative time by the number of times
the function was called.
I have some doubts about this approach -
With full compiler optimizations, I am not sure if the compiler is
making use of the facts that
(a). the input arguments to the function remain the same (and hence
the output is also the same) each time the function is called.
(b) that I am not making use of the output. (not printing to a file/
stdout).
So the compiler might be executing the function partially or in a
different manner. I do not want that, as it will obviously give a
misleading results.
At the same time, I do want "normal" optimizations. (Which do not make
use of points (a) and (b) mentioned above). Any suggestions for
this?
(The function can not contain any cout statements because that would
severely change its running time.)
order of microseconds. The approach I am using right now is to call
the function a sufficient number of times so that the cumulative time
is measurable, then divide the cumulative time by the number of times
the function was called.
I have some doubts about this approach -
With full compiler optimizations, I am not sure if the compiler is
making use of the facts that
(a). the input arguments to the function remain the same (and hence
the output is also the same) each time the function is called.
(b) that I am not making use of the output. (not printing to a file/
stdout).
So the compiler might be executing the function partially or in a
different manner. I do not want that, as it will obviously give a
misleading results.
At the same time, I do want "normal" optimizations. (Which do not make
use of points (a) and (b) mentioned above). Any suggestions for
this?
(The function can not contain any cout statements because that would
severely change its running time.)