11.2 Setting up the profiler
Before a profiling session can start several parameters must be set, using the function
set-up-profiler. There are four main areas to consider: the symbols to be profiled, the time interval between samples, the kind of profiling required, and the format of the output.
It is possible to keep track of every function called during a particular computation, but significant effort is involved in determining which symbols are suitable for profiling and in keeping track of the results. To minimize this effort you need to specify which symbols to profile, either by naming the required symbols, or by naming a package, all of whose symbols are profiled. The profiler first checks that these symbols have indeed got function definitions and are therefore suitable for profiling.
You might want to specify the time interval between interrupts. The resolution of this value is clearly dependent on the operating system. In most cases the default value, 10ms, is adequate. This number is important, because with these statistical methods of program profiling the accuracy of the results increases with the number of samples taken.
On Unix/Linux/FreeBSD systems the kind of profiling required may be set. This refers to what kind of time is monitored in order to determine when to interrupt the Lisp process. There are three possibilities for how the time interval is measured:
The time the Lisp process is actually executing plus the time that the system is executing on behalf of the process. This is called
Just the time that the process is actually executing. This is called
The actual elapsed time, called
The output can be presented as a tree of calls seen and a columnar report (
), or just the columnar report (
). You can restrict the data shown in several ways, helping you to focus on the slowest parts of your program.
Below is an example of setting up the profiler:
(set-up-profiler :symbols '(car cdr) :style :list)
Here the functions
are going to be profiled and the output will be just the columnar report.
The function set-up-profiler adds symbols to the
*profile-symbol-list*. The functions
remove-symbol-profiler can also be used to change the symbols profiled.
set-profiler-threshold can be used with
reset-profiler to control the effects of repeated profiler runs.
LispWorks User Guide and Reference Manual - 22 Dec 2009