Thanks for all the advises so far.
Ok, here's my monster that need to be timed in order to make a comparison:
(it's about the control digit of SEDOL numbers
http://en.wikipedia.org/wiki/SEDOL ):
knip _ [] = Nothing
knip k xs = Just (splitAt k xs)
ip xs = sum . zipWith (*) xs
an = ['0'..'9']++['A'..'Z']
s = take 841 $ cycle "0987654321"
f = \xs -> xs ++ [(sna!!).ip [1,3,1,7,3,9]. map (flip (fromJust .) an .
findIndex . (==))$xs]
Here's my try for timing:
*Main> (foldl1 (\x y -> f y) .concat.replicate 1000000 $ unfoldr (knip
6) an)
"UVWXYZ7"
(1.31 secs, 330291000 bytes)
(It's incl. the construction of the test list, as is in the language to
compare )
I need the whole list to be evaluated.
Interpreted mode IS A MUST :-)
BTW I increased stack size
thanks
Don Stewart schreef:
bradypus:
Suppose I've:
f = map g
I want to know how much time it takes (interpreted mode) to fully
process list xs (at least 1e6 elements) with function g. Is it
sufficient to execute:
*Main> last . f $ xs
<result>
(x.xx secs, yyyyyyyyyyy bytes)
Are there any hidden difficulties involved?
Reason is: comparing timings Haskell vs an interpreted language without
laziness.
If you care about timings, it's probably a better idea to compile the
code (with optimisations on), to get a better idea of what the code
would do in a production environment.
You could then just time the binary,
main = print . sum $ ....
ghc -O2 A.hs --make
time ./A
-- Don
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe