Hi,

I have been trying to profile code by putting in timing function at the start and end of the function(a function may call some other function and so on ) just before the return statement if the function returns something. The time is calculated in milliseconds.

I wanted to know if this is correct way of finding out how much time a function takes to execute . Is this correct ? The code to be profiled is in C .

Thank you.

-Plf

That depends on your OS and compiler.

With Linux / GCC for example, there is an additional utility call 'gprof', which does what you're trying to do automatically for every function (no need for you to edit code).

That depends on your OS and compiler.

With Linux / GCC for example, there is an additional utility call 'gprof', which does what you're trying to do automatically for every function (no need for you to edit code).

Hi,

Thanks for the response.

I think gprof has issues with multithreading. OS is Linux , compiler GCC . Actually I have been trying to profile code for handlers written in C for the apache web server.

But will timing functions yield correct result ?

Thank you.

-Plf

> I think gprof has issues with multithreading.
You know this for a fact, or is it just "heresay" rumor from long ago.

Even if it is true, you can still get some useful information by arranging a single-threaded test.

> But will timing functions yield correct result ?
By it's nature, timing is a slightly intrusive activity, which you have to be mindful of at times.

This article has been dead for over six months. Start a new discussion instead.