Re: comparing algorithm perf.



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.
    ... HASM a écrit: ... You can only monitor a "full program", and I don't want initialisations ... 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: Do...Loop search execution problem
    ... I've patched some code together for a script that will ... delete an icon when the script detects that the cd the icon is linked ... this code needs to be in the loop, you need to reexecute the query to check ... dim aCount ...
    (microsoft.public.scripting.vbscript)
  • 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)