[Haskell-cafe] measure a function in ghci

Jochem Berndsen jochem at functor.nl
Wed Jun 3 15:04:06 EDT 2009


Nico Rolle wrote:
> is there a quick way to check which function is doing the job quicker?
> i have 2 functions which i want to compare.
> both give the same output but they do it in different manner.
> i want to test which one is faster.
> i use ghci.

For simple testing in the interactive environment, use
:set +s
and after each evaluation the memory usage and the number of elapsed
seconds will be displayed.

If you want more, look up the profiling support in the documentation of GHC
http://www.haskell.org/ghc/docs/latest/html/users_guide/profiling.html
GHC provides both memory and time profiling.

Regards,

-- 
Jochem Berndsen | jochem at functor.nl
GPG: 0xE6FABFAB


More information about the Haskell-Cafe mailing list