On Wed, Feb 19, 2014 at 5:53 PM, Gregory Collins <greg@gregorycollins.net> wrote:
This version is about 2x as fast as OP's on my system (look at h2.hs): https://gist.github.com/gregorycollins/9103248 

$  time ./dist/build/h1/h1 50000000 +RTS -A4M > /dev/null
./dist/build/h1/h1 50000000 +RTS -A4M > /dev/null  23.88s user 0.06s system 99% cpu 24.003 total

$  time ./dist/build/h2/h2 50000000 +RTS -A4M > /dev/null
./dist/build/h2/h2 50000000 +RTS -A4M > /dev/null  13.57s user 0.09s system 99% cpu 13.706 total

$  time ./dist/build/h3/h3 50000000 +RTS -A4M > /dev/null
./dist/build/h3/h3 50000000 +RTS -A4M > /dev/null  24.24s user 0.18s system 99% cpu 24.490 total

The "system" number here is especially telling: this program is spending almost all of its time in syscalls.

You're reading it wrong. Using that last one:

24.2s on-CPU time in user mode
0.18s on-CPU time in system mode (kernel/syscalls)
99% of its total run time was actually spent on cpu (instead of, say, I/O wait)
24.490 total run (wall) time

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net