12.3.2 Programmatic control of profiling

Your program can control profiling. This is useful when you want to profile only a part of the program.

In your program, call start-profiling start collecting profiling information. Call stop-profiling with print nil to temporarily stop collecting, or call stop-profiling with print t to stop collecting and print the results. At any point you can call set-process-profiling to modify the set of processes for which profiling information is being (or will be) collected.

For example:

;; start profiling, current process only
(start-profiling :processes :current)
;; temporarily suspend profiling
(stop-profiling :print nil)
;; resume profiling
(start-profiling :initialize nil)
;; now, all processes are interesting
(set-process-profiling :set :all)
;; stop profiling and print the results

Note: you cannot call start-profiling inside the scope of the macro profile or while the graphical Profiler is profiling, because the two profiling modes are incompatible.

LispWorks User Guide - 11 Mar 2008