measure a function in ghci

hi there 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. thanks regards

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@functor.nl GPG: 0xE6FABFAB

On Wed, Jun 3, 2009 at 11:47 AM, Nico Rolle
hi there
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.
Be wary of timing things in GHCi. By default there are no optimizations in ghci so you could find that one implementation is much worse than the other but the situation might be completely different when optimizations are enabled. I'm pretty sure if you start ghci with the -O flag that it will use optimizations. Jason

Jason Dagit
Be wary of timing things in GHCi. By default there are no optimizations in ghci so you could find that one implementation is much worse than the other but the situation might be completely different when optimizations are enabled. I'm pretty sure if you start ghci with the -O flag that it will use optimizations.
...or if you compile your module first (ghc -c), I believe GHCi will use the compiled code. -k -- If I haven't seen further, it is by standing in the footprints of giants

Just use unamb[1] and let the program decide which to use at runtime!
Just kidding, but only sort of :)
Dan
[1] http://www.haskell.org/haskellwiki/Unamb
On Wed, Jun 3, 2009 at 2:47 PM, Nico Rolle
hi there
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.
thanks
regards _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (5)
-
Daniel Peebles
-
Jason Dagit
-
Jochem Berndsen
-
Ketil Malde
-
Nico Rolle