One embodiment of the present invention provides a system for performing
time measurements during instrumentation-based profiling. The system
operates by first measuring time required to execute instrumentation code
in isolation. Next, it receives the code to be profiled (user
application), inserts the instrumentation code into it, and executes this
combined code. The system then measures the time it takes to execute the
combined code. Finally, it subtracts the previously obtained
instrumentation code execution time from the total combined code
execution time, thus obtaining the exact execution time for the user
application.