Int vs Word performance?
claus.reinke at talk21.com
Thu Feb 26 18:28:48 EST 2009
Looking at prelude/PrelRules.hs has reminded me of an old
conundrum: if I switch from Int to Word, should I expect any
A while ago, I needed lots of fairly small positive numbers,
together with a small number of flags for each, so I thought
I'd switch from Int to Word, and map the flags to bits. But
the performance dropped so drastically that I went back
to Int, slightly complicating the bitmaps. I didn't expect that,
and I can't see any builtin rules for Int that would have no
Here is a trivial example with drastic difference between
T = Int and T = Word (~2.5x here):
main = print $ foldl' (+) 0 [1..100000000::T]
What am I missing here?
Also, in the real code I ended up seeing things like this in
the -ddump-simpl output for the bit-fiddling code:
Is that likely to cost me a lot or are these conversions cheap?
More information about the Glasgow-haskell-users