Information about how much time in spent in a function, based on the input of this function
- by olchauvin
Is there a (quantitative) tool to measure performance of functions based on its input?
So far, the tools I used to measure performance of my code, tells me how much time I spent in functions (like Jetbrain Dottrace for .Net), but I'd like to have more information about the parameters passed to the function in order to know which parameters impact the most the performance.
Let's say that I have function like that:
int myFunction(int myParam1, int myParam 2) {
// Do and return something based on the value of myParam1 and myParam2.
// The code is likely to use if, for, while, switch, etc....
}
If would like a tool that would allow me to tell me how much time is spent in myFunction based on the value of myParam1 and myParam2.
For example, the tool would give me a result looking like this:
For "myFunction" :
value | value | Number of | Average
myParam1 | myParam2 | call | time
---------|----------|-----------|--------
1 | 5 | 500 | 301 ms
2 | 5 | 250 | 1253 ms
3 | 7 | 1268 | 538 ms
...
That would mean that myFunction has been call 500 times with myParam1=1 and myParam2=5, and that with those parameters, it took on average 301ms to return a value.
The idea behind that is to do some statistical optimization by organizing my code such that, the blocs of codes that are the most likely to be executed are tested before the one that are less likely to be executed.
To put it bluntly, if I know which values are used the most, I can reorganize the if/while/for etc.. structure of the function (and the whole program) to optimize it.
I'd like to find such tools for C++, Java or.Net.
Note: I am not looking for technical tips to optimize the code (like passing parameters as const, inlining functions, initializing the capacity of vectors and the like).