
Hi, Am Dienstag, den 29.04.2014, 17:31 +0100 schrieb Niklas Hambüchen:
This is just a short notice that using
foldl' (+) 0 [0..100000::Int]
is over 10 times slower than using
flip execState 0 $ forLoop (0 :: Int) (< n) (+1) $ \i -> do x <- get put $! x + i
with `loopFor` as on https://github.com/nh2/loop.
Did you look at the GHC Core generated? When starting to investigate performance issues, reading Core simply is required – otherwise it’s like search for a lost plain while refusing to look under the water surface. So can you compile your code with -ddump-simpl (and possibly flags -dsuppress-uniques and -dsuppress-module-prefixes that make it more readable) and compare the results: Any obvious differences, like unboxing to Int# used in one place and not in the other? If you need help deciphering core, paste the relevant bits in a mail to this thread and we can help you. Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org