Re: comparing algorithm perf.



Thierry MARTIN <thierry-martin@xxxxxxxxxxx> writes:
I would like to compare the perf of two algorithms written in C.

I feel that time-based method are not enough reliable (for instance
time (1) gives different results for the same program).

So, I would like to do a comparison based on the number of CPU
instructions required to process the same data in both cases.

profil (2) seems to be a good starting point, unfortunatly, I miss
some code sample to use it...

If sampling at 100Hz is sufficient that you actually get useful data,
you could simple compile a test program using -g -pg and run gprof on
the output. But you should probably have a look at OProfile
(http://oprofile.sourceforge.net) or some other 'high-resolution'
profiler instead (I have only used OProfile so far, but there are
others).

.