[Haskell-cafe] ANNOUNCE: StrictBench 0.1 - Benchmarking code through strict evaluation

Magnus Therning magnus at therning.org
Mon Jun 8 06:58:35 EDT 2009


On Mon, Jun 8, 2009 at 8:20 AM, Niemeijer, R.A.<r.a.niemeijer at tue.nl> wrote:
> Hello everyone,
>
> In the last month or so, I've found myself using the following snippet a lot:
>
> import Control.Parallel.Strategies
> import Test.BenchPress
>
> bench 1 . print . rnf
>
> This snippet fully evaluates a value and prints how long it took to do so. I regularly use it to see where the bottlenecks lie in my algorithms.  It has the minor annoyance, however, that it prints a lot of information (min, max, mean, median, percentiles) that is all identical, because I only run it once. The reason I only run it once is that I'm typically evaluating a pure value, which means that any subsequent attempts to benchmark the evaluation time will take no time at all, since it has already been evaluated.
>
> To solve this, I decided to write a small library to make this process easier and only print the time taken once. The result is StrictBench, which can be found at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/StrictBench.

Is there no way to force repeated evaluation of a pure value?  (It'd
be nice to be able to perform time measurements on pure code so that
it's possible to compare Haskell implementations of algorithms to
implementations in other languages, without running into confounding
factors.)

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the Haskell-Cafe mailing list