[Openmcl-devel] Profiling lisp code

Adlai Chandrasekhar munchking at gmail.com
Wed Nov 18 09:59:40 PST 2009

On Wed, 18 Nov 2009, Hans Hübner wrote:
> A simple, deterministic profiler built on the ADVICE facility is
> included with CCL in the tools/advice-profiler/ directory.  It can be
> loaded using asdf and integrates with the profiling facility of Slime.
> Unfortunately, I have never come around to write documentation for
> it.  There is documentation for the system-level statistical profiling
> tools on Linux and Mac OS in the CCL manual:
> http://ccl.clozure.com/ccl-documentation.html#Profiling
> -Hans

I've used this profiler several times. It's nothing like SB-SPROF,
however, I've found that it gives pretty detailed timing and was
_very_ easy to set up with a bit of help in #ccl from rme. Thank you
rme for the help, and Hans for putting it together!

Here's what works for me:

  - Put the following lines in your ~/.ccl-init.lisp file:

      (require :asdf)                  ; Probably already there
      (open-shared-library "librt.so") ; This might be Linux-specific
      (load #P"ccl:tools;advice-profiler;profiler.asd")
      (asdf:oos 'asdf:load-op :profiler)

  - Start CCL, load your code, then use the fairly "dwim" macro
    PROFILER:PROFILE to pick which code to profile. It's got
    a detailed docstring, just refer to that.

  - (tagbody
     loop    (your-code:run)
             (profiler:report) ; M-. for &key arguments
             (when (cl-user:done-profiling-p)
               (go profit!))
             (cl-user:frob :your-code)
             (go loop))

Hope that helps,

  - Adlai

More information about the Openmcl-devel mailing list