[Haskell-cafe] timing question

Don Stewart dons at galois.com
Sun Aug 3 13:32:09 EDT 2008

> 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

More information about the Haskell-Cafe mailing list