11.2 Setting up the profiler
Before a profiling session can start several parameters must be set, using the function
set-up-profiler
. This function is introduced here and the full syntax is given in the
LispWorks Reference Manual
. There are three main areas to consider: the symbols to be profiled, the time interval between samples, and the kind of profiling required.
-
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. For example, the greatest number of interrupts that can be sent to a process under SunOS is 100 per second. This number is important, because with these statistical methods of program profiling the accuracy of the results increases with the number of samples taken. In most cases the default values, 10 ms, is adequate.
-
On Unix/Linux 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
profile time
.
Just the time that the process is actually executing. This is called
virtual time
.
The actual elapsed time, called
real time
.
Below is an example of setting up the profiler:
(set-up-profiler :symbols '(car cdr))
Here the functions
car
and
cdr
are going to be profiled.
The function
set-up-profiler
adds symbols to the
*profile-symbol-list*
. The functions
add-symbol-profiler
and
remove-symbol-profiler
can also be used to change the symbols profiled.
The function
set-profiler-threshold
can be used with
reset-profiler
to control the effects of repeated profiler runs.
LispWorks User Guide - 7 Jul 2004