Hi,
I use MINGW and I have a program made by me in which I have included my own profile system. I can't use gcc profile because I have thread and gprof dont support thread althoug of the two thread I have, I only want to measure one of them.
What I do is a system where a function is call: the first instruction in the function is a call to start the function time counter. When exits, a call is made to stop time function. If in between, the caller time counter is stopped, put in a stack, and a start a new counter. When exit the time counter is stopped, then put again the caller time counter on.
Something like this:
I use clock() to measure all this. do you find something wrong with this approach? do you think the result are reasonble?Code:function a1(int x) { PROFILE_START("a1"); if (x==1) { a2(x); // a1 counter is stopped,when return from a2 is started PROFILE_STOP("a1"); return ; } else { x+=1; } PROFILE_STOP("a1"); } function a2(int x) { PROFILE_START("a2"); x += 5; PROFILE_STOP("a2"); }
My test show coherent results, but I am not sure if the system is detailed or good timer. do you think small function are measured correctly?
thx all.