[Haskell-cafe] How to correctly benchmark code with Criterion?
Alfredo Di Napoli
alfredo.dinapoli at gmail.com
Thu Oct 18 11:49:03 CEST 2012
I don't know if you have already read them,
but Tibell's slides on High Performance Haskell are pretty good:
There is a section at the end where he runs several tests using Criterion.
On 18 October 2012 11:45, Claude Heiland-Allen <claude at mathr.co.uk> wrote:
> Hi Janek,
> On 18/10/12 10:23, Janek S. wrote:
>> during past few days I spent a lot of time trying to figure out how to
>> write Criterion benchmarks,
>> so that results don't get skewed by lazy evaluation. I want to benchmark
>> different versions of an
>> algorithm doing numerical computations on a vector. For that I need to
>> create an input vector
>> containing a few thousand elements. I decided to create random data, but
>> that really doesn't
>> matter - I could have as well use infinite lists instead of random ones.
> The question is how to generate data so that its evaluation won't be
>> included in the benchmark.
> Something like this might work, not sure what the canonical way is.
> main = do
> let input = L.dataBuild gen
> evaluate (rnf input)
> bench "Lists" $ nf L.benchThisFunction input
> I did use something like this in practice here:
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe