[Haskell-cafe] newbie timing question
Donald Bruce Stewart
dons at cse.unsw.edu.au
Fri Jan 26 18:04:54 EST 2007
seanmcl:
>
> Hello,
>
> I'm trying to write a simple function to time an application.
>
> -- this doesn't work
>
> time f x =
> do n1 <- CPUTime.getCPUTime
> let res = f x in
> do n2 <- CPUTime.getCPUTime
> return (res,n2 - n1)
>
> On a function that takes 8 seconds to complete, returns
> (True,46000000)
>
> According to the documentation, this time is in picoseconds, making
> this 46 microseconds.
That thunk you're allocating with 'let' isn't going to help much ;)
http://haskell.org/haskellwiki/Timing_computations
Cheers,
Don
More information about the Haskell-Cafe
mailing list