All Manuals > LispWorks IDE User Guide > 23 The Profiler

23.1 Introduction

The Profiler provides a way of monitoring Lisp functions during the execution of your code. It is likely that you can make your code more efficient using the data that the Profiler displays.

The Profiler helps you to identify functions which are called frequently or are particularly slow. You should concentrate your optimization efforts on these routines.

The Profiler gives you an easy way of choosing which functions you wish to profile, which code you want to run while profiling, and provides you with a straightforward display of the results of each profile.

When code is being profiled, the Lisp process running that code is interrupted regularly at a specified time interval. At each interruption, the Profiler scans the execution stack and records the name of every function found, including a note of the function at the top of the stack. Moreover, a snapshot of the stack is recorded at each interruption, so we know not merely how many times we reach a function call, but also how we reached that call.

When profiling stops (that is, when the code being profiled has stopped execution) the Profiler presents the data that it has collected.

To create a Profiler, choose Window > Tools > Profiler or click in the LispWorks toolbar.

In the next section, we assume you are profiling a call to the function foo defined as follows:

(in-package "CL-USER")
 
(defun baz (l)
  (dotimes (i l)))
 
(defun quux (l)
  (dotimes (i l)))
 
(defun bar (n l)
  (dotimes (i n)
    (baz l))
  (dotimes (i n)
    (quux (floor l 2))))
 
(defun foo (n l)
  (bar n l))

LispWorks IDE User Guide (Macintosh version) - 01 Dec 2021 19:36:36