C/Haskell speed comparisons

Ian Lynagh igloo at earth.li
Mon Sep 19 21:05:50 EDT 2005


Hi all,

Quite often in darcs we want to do a simple loop over a chunk of memory,
looking for the first whitespace character or somesuch.

Historically this has been done by writing a small snippet of C, but
this has a number of downsides (less type safety in the C code,
Int/int/HsInt/CInt mismatches, code artificially separated, complicates
the Makefiles, have to write C code), so I'd like to replace them with
little bits of Haskell.

However, it would be easier to convince people that this is the right
thing to do if there was no slow-down involved, so I've put some
benchmarks together. Hopefully this will help find some cases where ghc
is generating poor code, and perhaps help to spot regressions (although
it's hard to spot that automatically currently).

Essentially each test has n modules, each of which (are supposed to) do
the same thing, and it compares certain pairs and it works out how much
slower one is than the other on various test sizes. I arbitrarily
declared x1.1 to be too slow.

The code is at http://urchin.earth.li/~ian/bench/ and the results I get
for ghc 6.4.1 are at http://urchin.earth.li/~ian/bench/all.html
(interestingly some of the slowdowns I was trying to measure turned out
to be speed/ups/).


Thanks
Ian



More information about the Glasgow-haskell-users mailing list