Re: comparing algorithm perf.



Sorry for my late thanks ;-)...

I'll give it a try.

Thierry


HASM a écrit :
Thierry MARTIN <thierry-martin@xxxxxxxxxxx> writes:

I see two problems with "time (1)" solution:
1. You can only monitor a "full program", and I don't want initialisations
stuff to be taken into acount in my comparison. I want to compare two
equivalent loops that are part of two distinct programs.
Both algos may take different time to initialise, I don't care about it.

Loop around the section you want to time with calls to times(2) before and
after the loop. You may need to reinitialize the data that particular code
section uses.

#include <sys/times.h>
...
struct tms start, end;
...
times (&start);
<loop here over your code>
times (&end);

then
(end.tms_utime - start.tms_utime) / (double) loop_count
will give you user time, per iteration
(end.tms_stime - start.tms_stime) / (double) loop_count
will give you system time, on your behalf.
And cutime and cstime will do the same for all children processes.

-- HASM
.



Relevant Pages

  • Re: comparing algorithm perf.
    ... You can only monitor a "full program", and I don't want initialisations ... stuff to be taken into acount in my comparison. ... after the loop. ...
    (comp.os.linux.development.apps)
  • How to make only one thread sleep?
    ... creating detached worker threads. ... inserts them into a queue for the factory thread to extract. ... This design was chosen so that the monitor loop can continue running ...
    (comp.lang.perl.misc)
  • Re: Setting onMouseOver dynamically
    ... assumed that as the loop went through, ... Can I therefore also clarify - does getElement.onmouseout - monitor ... Earlier in my code I use the exact same lines outside the for loop and ...
    (comp.lang.javascript)
  • Re: Is inifinite loop not a good practice?
    ... that infinite loop is a bad programming practice. ... next monitor run. ... The problem with the world is stupidity. ...
    (comp.lang.python)
  • Re: Save data
    ... Each shared variable has no fixed value, I have to use a white until stop to monitor each shared variable. ... So I can`t use the for loop, and also I need to read the 20 shared variable at the same time. ... thanksMessage Edited by enzo78 on 07-01-2008 12:06 PM ...
    (comp.lang.labview)