Thread View: comp.lang.functional
2 messages
2 total messages
Started by tromp
Sat, 12 Mar 2005 19:48
my haskell program is 60 times slower than java; how to speed up?
Author: tromp
Date: Sat, 12 Mar 2005 19:48
Date: Sat, 12 Mar 2005 19:48
40 lines
2417 bytes
2417 bytes
I recently ported my Fhourstones integer benchmark, previously
available
in both C and Java, to Haskell.
This allowed for significantly clearer and more concise code,
with much improved modularity.
Unfortunately, performance went down the drain:( On my desktop PC, the
java version
examines over 1700K positions per second, while Haskell strains to get
25 Kpos/sec.
Source of all versions may be found on
http://www.cwi.nl/~tromp/c4/fhour.html
Curiously, profiling shows all 3 versions spend between 1/5 and 1/3
of their time on the following function for testing 4 in a row in 64bit
bitboards:
isWon :: Word64 -> Bool
isWon bb = dir 1 /= 0 || dir height /= 0 ||
dir height' /= 0 || dir height'' /= 0 where
dir d = let t = bb .&. (bb `shiftR` d) in t .&. (t `shiftR` (2*d))
So this simple strict function alone appears to be dozens times slower
in Haskell.
I think I've already added strictness annotations in all the relevant
places.
Is there any hope of getting say, within a factor of 4 of java
performance,
without sacrificing (too much of) the clarity of the source code?
regards,
-John
PS: the haskell version has slightly different move ordering and so
doesn't reproduce the test results of the other versions exactly,
but this shouldn't affect the speed as measured in pos/sec.
Re: my haskell program is 60 times slower than java; how to speed up?
Author: Tomasz Zielonka
Date: Sun, 13 Mar 2005 11:35
Date: Sun, 13 Mar 2005 11:35
11 lines
1391 bytes
1391 bytes
tromp wrote: > Unfortunately, performance went down the drain:( On my desktop PC, the > java version examines over 1700K positions per second, while Haskell > strains to get 25 Kpos/sec. Important questions: - which Haskell compiler did you use? - how did you compile it? Best regards Tomasz
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads