Re: comparing algorithm perf.
- From: Thierry MARTIN <thierry-martin@xxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 14:42:43 +0100
Bernhard Agthe a écrit :
I would like to compare the perf of two algorithms written in C.
time
Ensure they're running a long time, so give them lots of input or run
them 1000 times in a row.
I feel that time-based method are not enough reliable (for instance time
(1) gives different results for the same program).
Read the documentation for time (1). It gives three values:
1st real
2nd user
3rd sys
The first one is Wall-Clock time.
The second one is the time, the CPU spent in your program.
The third one is the time, the CPU spent executing system requests (e.g.
reading a file) on your program's behalf.
If the User time is in the minutes-range and the first one takes
considerably longer than the other one, you have your result. If they
take approximately the same time, you need to use more iterations ;-) If
they still only differ marginally, you also have your result.
It's the same with using gprof: gprof is based on an approximately 100Hz
frequency. If you try to measure 10ms, you'll get bad results. If you
measure 100sec you get very good results...
Ciao...
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.
2. if you launch time twice with the same program and same data, you get two different results, which lets me think it depends on the load of your machin.
Anyway, thank for you answer.
I will have a look at gprof...
.
- Follow-Ups:
- Re: comparing algorithm perf.
- From: LEE Sau Dan
- Re: comparing algorithm perf.
- From: David Schwartz
- Re: comparing algorithm perf.
- From: Ed Prochak
- Re: comparing algorithm perf.
- From: HASM
- Re: comparing algorithm perf.
- References:
- comparing algorithm perf.
- From: Thierry MARTIN
- Re: comparing algorithm perf.
- From: Bernhard Agthe
- comparing algorithm perf.
- Prev by Date: Re: comparing algorithm perf.
- Next by Date: sending large buffers to wine applications
- Previous by thread: Re: comparing algorithm perf.
- Next by thread: Re: comparing algorithm perf.
- Index(es):
Relevant Pages
|