
Daniel, here another feedback:
F:\MeineUebungen>ghc -O2 -fexcess-precision -fvia-C -optc-O3 -o luaLoop --make p
085-pi_lualoop.hs
[1 of 1] Compiling Main ( p085-pi_lualoop.hs, p085-pi_lualoop.o )
Linking luaLoop.exe ...
F:\MeineUebungen>echo '0.00000001' | time ./luaLoop
Eingegebene Zeit kann nicht übernommen werden.
Geben Sie die neue Zeit ein:
F:\MeineUebungen>luaLoop +RTS -sstderr -RTS
luaLoop +RTS -sstderr
EPS:
0.00000001
3.1415926485894725
61,428 bytes allocated in the heap
1,316 bytes copied during GC
4,564 bytes maximum residency (1 sample(s))
11,820 bytes maximum slop
1 MB total memory in use (0 MB lost due to fragmentation)
Generation 0: 0 collections, 0 parallel, 0.00s, 0.00s elapsed
Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed
INIT time 0.02s ( 0.00s elapsed)
MUT time 8.06s ( 16.83s elapsed)
GC time 0.00s ( 0.00s elapsed)
EXIT time 0.00s ( 0.00s elapsed)
Total time 8.08s ( 16.83s elapsed)
%GC time 0.0% (0.0% elapsed)
Alloc rate 7,604 bytes per MUT second
Productivity 99.8% of total user, 47.9% of total elapsed
-- Markus
On Mon, Feb 1, 2010 at 3:08 PM, Markus Böhm
Daniel, I use GHC 6.12.1 and Windows XP. The time command doesn't seem to work. It says in German: specified time can't be read. Give a new time.
-- Markus
On Mon, Feb 1, 2010 at 2:52 PM, Daniel Fischer
wrote: Am Montag 01 Februar 2010 14:31:40 schrieb Markus Böhm:
Daniel, with LuaJIT it needs 1.45 sec cpu-time on my machine with attached variant.
That's pretty fast.
I compiled all our Haskell variants with ghc --make -O2.
Well, GHC isn't as good at loop-optimising as gcc is. Depending on the loop, the via-C compiled binaries are between 1.4 and 2.3 times faster than the NCG compiled.
I don't know about -fvia-C, have to find out. I hope I didn't distract You with my Lua variant.
No sweat.
In any case thank You very much for your advice. Markus.
You're welcome.
Can you try the below with
ghc -O2 -fexcess-precision -fvia-C -optc-O3 -o luaLoop --make Whatever.hs
and run with
echo '0.00000001' | time ./luaLoop
? It's a fairly direct translation of the Lua code, and it runs here more or less equally fast as (gcc compiled) C-loops.
================================= module Main (main) where
main :: IO () main = do putStrLn "EPS:" eps <- readLn :: IO Double print $ 4*calcPi eps
calcPi :: Double -> Double calcPi eps = go False 1 3 where go bl p1 i | 4*abs(p2-p1) < eps = p1 | otherwise = go (not bl) p2 (i+2) where p2 | bl = p1+1/i | otherwise = p1-1/i
==================================