[Haskell-cafe] timing question

Arie Groeneveld 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  
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
>
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080805/ff7335ff/attachment.htm


More information about the Haskell-Cafe mailing list