Best recursion choice for "penultimax"

Simon Marlow simonmar@microsoft.com
Mon, 25 Nov 2002 17:29:46 -0000


> Some quick tests with Hugs +s on a example list that I constructed
> with 576 elements give food for thought:
>=20
>                       reductions     cells
>    my one liner          4035        11483
>    tournament            7053        12288
>    your penultimax      16715        20180
>    your penultimax2      7466        10344
>    your penultimax3      8605        13782

And with GHC -O, the results are quite different:

    Mark's one liner     0.60s
    tournament           0.25s
    your penultimax      0.26s
    your penultimax2     0.25s
    your penultimax3     0.25s

the tests were with random numbers (different seed each time), but there
was only a little little fluctuation from run to run.  I specialised all
the algorithms to Int.

Hugs doesn't do much optimisation, so the reductions/cells counts tend
to vary quite a bit between programs which GHC will optimise to the same
or similar code.  The moral, as usual, is YMMV...

Cheers,
	Simon