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:
C version:
$ 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.
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,