3 ms·
I tried to reproduce the results, but the Haskell bit failed to compile on my Mac with the -fvia-C flag. Without the -fvia-C flag, the Haskell version takes abo
by it 15y ago
I tried to reproduce the results, but the Haskell bit failed to compile on my Mac with the -fvia-C flag. Without the -fvia-C flag, the Haskell version takes about 11 times as long to run as the C version. A simple Go version runs at the same speed as the C version.
I posted some code to run the comparison at https://github.com/ijt/fast-as-c-article https://github.com/ijt/fast-as-c-article. Here are the results:
[ issactrotts ~/haskell/fast-as-c-article ] ./compare
== cmean ==
gcc -O2 -o cmean cmean.c
mean: 500000000.500000
real 0m0.774s
user 0m0.770s
sys 0m0.002s
== gomean ==
6g gomean.go
6l -o gomean gomean.6
mean: 500000000.500000
real 0m0.776s
user 0m0.769s
sys 0m0.003s
== hsmean ==
ghc -O2 hsmean.hs -optc-O2 -fvia-C --make
[1 of 1] Compiling Main ( hsmean.hs, hsmean.o )
In file included from /usr/local/Cellar/ghc/7.0.4/lib/ghc-7.0.4/include/Stg.h:230,
from /var/folders/g2/ylbqfw5533n65z6qkxljg0_h0000gn/T/ghc23078_0/ghc23078_0.hc:3:0:
/usr/local/Cellar/ghc/7.0.4/lib/ghc-7.0.4/include/stg/Regs.h:177:0:
sorry, unimplemented: LLVM cannot handle register variable ‘R1’, report a bug
make: *** [hsmean] Error 1
== hsmean_nollvm ==
ghc -O2 hsmean.hs -optc-O2 --make -o hsmean_nollvm
[1 of 1] Compiling Main ( hsmean.hs, hsmean.o )
Linking hsmean_nollvm ...
ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
mean: 500000000.067109
real 0m8.886s
user 0m8.863s
sys 0m0.018s
- dons 15y agoThese days you'd use the -fllvm flag