The profiler has two distinct modes. You can use both in the same session, but not at the same time.
To use either mode, you must first call set-up-profiler to load the profiler and set its parameters including the output format.
The macro profile simply profiles all processes while a body of code is run, as described in Using the macro profile. Start profiling this way if you don't see a need to use the alternate mode.
Alternatively the functions start-profiling,
stop-profiling and
set-process-profiling offer programmatic control over when profiling occurs and which processes are profiled. This is described in Programmatic control of profiling.
The function do-profiling is a convenience function which allows you to profile multiple threads using start-profiling and stop-profiling.
To profile your Lisp forms enter:
(profile <forms>)
This evaluates the forms as an implicit progn
and prints the results, according to the parameters established by set-up-profiler.
Note:
you cannot use profile (or the graphical Profiler tool) after a call to start-profiling and before a call to stop-profiling with print t
, because the two profiling modes are incompatible.
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.
;; start profiling, current process only
(start-profiling :processes :current)
(do-interesting-work)
;; temporarily suspend profiling
(stop-profiling :print nil)
(do-uninteresting-work)
;; resume profiling
(start-profiling :initialize nil)
(do-more-interesting-work)
;; now, all processes are interesting
(set-process-profiling :set :all)
(do-some-more-interesting-work)
;; stop profiling and print the results
(stop-profiling)
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 and Reference Manual - 13 Feb 2015