[Haskell-cafe] Reasoning about performance
Carter Schonwald
carter.schonwald at gmail.com
Wed Sep 4 18:15:59 CEST 2013
Awesome/ thanks for sharing. It's worth noting that criterion is also
pretty great for microbenchmarks too. On my machine I get pretty good
timing accuracy on anything that takes more than 20 nanoseconds.
On Wednesday, September 4, 2013, Scott Pakin wrote:
> On 09/03/2013 06:02 PM, Carter Schonwald wrote:
>
>> It's also worth adding that ghci does a lot less optimization than ghc.
>>
>
> Yes, I discovered that before I posted. Note from my initial message
> that I used ghc to compile, then loaded the compiled module into ghci:
>
> Prelude> :!ghc -c -O2 allpairs.hs
> Prelude> :load allpairs
> Ok, modules loaded: AllPairs.
> Prelude AllPairs> :m +Control.DeepSeq
> Prelude Control.DeepSeq AllPairs> :show modules
> AllPairs ( allpairs.hs, allpairs.o )
>
> Likewise, the best tool for doing performance benchmarking is the
>> excellent Criterion library.
>>
>
> Ah, I didn't know about Criterion; that does look useful. For the
> record, here's what Criterion reports for my three all-pairs
> implementations:
>
> Prelude Criterion.Main AllPairs> defaultMain [bench "allPairs1" $ nf
> allPairs1 [1..10000]]
> ...
> mean: 5.184160 s, lb 5.156169 s, ub 5.212516 s, ci 0.950
> std dev: 144.4938 ms, lb 127.3414 ms, ub 164.8774 ms, ci 0.950
>
> Prelude Criterion.Main AllPairs> defaultMain [bench "allPairs2" $ nf
> allPairs2 [1..10000]]
> ...
> mean: 2.310527 s, lb 2.290451 s, ub 2.329349 s, ci 0.950
>
> Prelude Criterion.Main AllPairs> defaultMain [bench "allPairs3" $ nf
> allPairs3 [1..10000]]
> ...
> mean: 10.05609 s, lb 10.02453 s, ub 10.08866 s, ci 0.950
>
> As before, allPairs2 is the fastest, followed by allPairs1, with
> allPairs3 in last place.
>
> -- Scott
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130904/7a3553a9/attachment.htm>
More information about the Haskell-Cafe
mailing list