> The question remains: is the Orwellian law true here? Am I
> comparing apples to oranges? Maybe, but what choice do I have
> in Hugs? Should I use the timer functionality? But there is
> a note in "timer.c" that discourages it too. (The note is appended
> here). I wonder whether the strong wording of that note
> has a real justification or is it just a formal disclaim? 
> 
[..]
> --------- Excerpt from timer.c in Hugs source code distribution ------
> 
[..]
> It would be somewhat foolish to try to use the timings produced
> in this way for anything other than the purpose described above.
> In particular, using timings to compare the performance of different
> versions of an algorithm is likely to give very misleading results.
> The current implementation of Hugs as an interpreter, without any
> significant optimizations, means that there are much more significant
> overheads than can be accounted for by small variations in Hugs code."

As I understand it, this disclaimer means what it says.  The Hugs interpreter makes no 
particular effort to optimise the code before execution, and consequently misses a 
large number of optimisations upon which one normally relies when writing functional 
programs.  The mapping from Haskell to machine code is far less trivial than that from 
say C to machine code, and consequently for efficient code to result the compiler must 
be far cleverer.

So while Hugs gives you a reduction count (or even a millisecond duration), this is 
essentially meaningless: in a real application you would compile the code with an 
optimising compiler.  The effect this can have on your execution time can easily be 
more than merely a constant factor: it can change the order of your algorithm.

The real answer, as others have pointed out, is to use a profiler, which performs 
timings on the actual code output by the compiler you have chosen to use.  In the end, 
the only benchmark that makes any sense is running your real application under real 
conditions.

HTH.

--KW 8-)

-- 
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) ------------------------:
: PhD Student, Computer Laboratory, University of Cambridge, England. :
:  (and recently of the University of Glasgow, Scotland. [><] )       :
: Native of Antipodean Auckland, New Zealand: 174d47' E, 36d55' S.    :
: http://www.cl.cam.ac.uk/users/kw217/  mailto:[EMAIL PROTECTED]     :
:---------------------------------------------------------------------:



Reply via email to