[Haskell-cafe] How to benckmark a Word64 -> Bool?

Alois Cochard alois.cochard at gmail.com
Wed Feb 19 18:17:49 UTC 2014


Hi Charles,

Criterion might give you more precise results :
http://hackage.haskell.org/package/criterion

Cheers
On Feb 19, 2014 5:37 PM, "Charles-Pierre Astolfi" <cpa at crans.org> wrote:

> Hi,
>
> I have a Word64 -> Bool function called only012 that returns True iff the
> digits in base 10 are 0, 1 or 2.
> I wand to make sure that I'm competitive with C, so I wrote the following
> code:
>
> Haskell version:
> http://lpaste.net/100129
>
> C version:
> http://lpaste.net/100128
>
> $ ghc --make -O3 303only012.hs && time ./303only012 50000000 > /dev/null
> ./303only012 50000000 > /dev/null  21.44s user 0.41s system 91% cpu 23.754
> total
>
> $ g++ -O3 303only012.cpp -o 303cpponly012 && time ./303cpponly012 50000000
> > /dev/null
> ./303cpponly012 50000000 > /dev/null  13.87s user 0.03s system 95% cpu
> 14.577 total
>
> So there's a difference, but I'm not sure if it's related to my algorithm
> or related to IO/RTS.
>
> The core output of only012 looks quite tight: http://lpaste.net/100130
>
> Am I doing the IO part right, that is fast IO that is not screwing my
> benckmark? I'm not so sure about that since I use a convoluted way to print
> the boolean result in Haskell.
>
> Cheers,
> --
> Cp
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140219/0435a9b7/attachment.html>


More information about the Haskell-Cafe mailing list