How can I find exact elapsed time of a function in a binary executable?

41 Views Asked by At

For my research, I want to compare the exact run time of my program A and another program B. However, B source codes are not available for me. The program consists of some pre- and post- processing tasks which must be excluded from the run time.

How can I measure only the time required for the main function (i.e., without pre and post processing functions)?

The program is really fast and the run times (reported by the program itself) is almost lower than 1 second. (If I had the source code, I could put the main function within a loop to measure the elapsed time with more precision).
I think there may be some slow down functions (or emulators) to find the exact elapsed time, but I'm not sure if the method works.

Any idea to measure the function is appreciated.

(Platform: Fedora 17, That's likely the program is compiled with gcc with /O3 for optimization).

0

There are 0 best solutions below