开发者

Quicksort + Profiling

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

qsort [] = []
qsort (x:xs) = qsort (filt开发者_运维知识库er (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)

please help me out!


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

  • http://www.haskell.org/ghc/docs/latest/html/users_guide/profiling.html for more profiling options in GHC.
  • http://book.realworldhaskell.org/read/profiling-and-optimization.html for how to analyze the profiled info.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜