<div dir="ltr">Hi,<div><br></div><div>I have a Word64 -> Bool function called only012 that returns True iff the digits in base 10 are 0, 1 or 2.</div><div>I wand to make sure that I'm competitive with C, so I wrote the following code:</div>

<div><br></div><div>Haskell version:</div><div><a href="http://lpaste.net/100129">http://lpaste.net/100129</a><br></div><div><br></div><div>C version:</div><div><a href="http://lpaste.net/100128">http://lpaste.net/100128</a><br>

</div><div><br></div><div>$ ghc --make -O3 303only012.hs && time ./303only012 50000000 > /dev/null</div><div>./303only012 50000000 > /dev/null  21.44s user 0.41s system 91% cpu 23.754 total<br></div><div><br>

</div><div>$ g++ -O3 303only012.cpp -o 303cpponly012 && time ./303cpponly012 50000000 > /dev/null</div><div>./303cpponly012 50000000 > /dev/null  13.87s user 0.03s system 95% cpu 14.577 total<br></div><div>
<br>
</div><div>So there's a difference, but I'm not sure if it's related to my algorithm or related to IO/RTS.</div><div><br></div><div>The core output of only012 looks quite tight: <a href="http://lpaste.net/100130">http://lpaste.net/100130</a></div>

<div><br></div><div>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.</div><div><br></div>

<div>Cheers,</div><div><div><div><div>--  <br>Cp</div>
</div></div></div></div>