views:

121

answers:

1

Hello! i'm trying to profile a quicksort code. the code is as follows:

qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)

please help me out!

+5  A: 

Assuming you use GHC, you can enable profiling with the -prof flag (probably -auto-all and -caf-all for more detail).

Then you run your program with ./a.out +RTS -p to generate the profiling result in a.out.prof.

The profile only include the total time and memory spent on each function. Which may not be suitable for you, since there's only one function qsort. Compile the program normally and run with ./a.out +RTS -sstderr may have enough information already.

See

KennyTM