[Haskell-cafe] timing question
bradypus at xs4all.nl
Tue Aug 5 02:43:52 EDT 2008
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
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
(1.31 secs, 330291000 bytes)
(It's incl. the construction of the test list, as is in the language to
I need the whole list to be evaluated.
Interpreted mode IS A MUST :-)
BTW I increased stack size
Don Stewart schreef:
>> 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
>> (x.xx secs, yyyyyyyyyyy bytes)
>> Are there any hidden difficulties involved?
>> Reason is: comparing timings Haskell vs an interpreted language without
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe