063514ae1cb81acb8ec04cc1e8c11bbc9c212067
[sbcl.git] / contrib / sb-sprof / sb-sprof.texinfo
1 @node sb-sprof
2 @section sb-sprof
3 @cindex Profiler
4
5 The @code{sb-sprof} module provides an alternate profiler which works by
6 taking samples of the program execution at regular intervals, instead of
7 instrumenting functions like @code{profile} does. You might find
8 @code{sb-sprof} more useful than @code{profile} when profiling functions
9 in the @code{common-lisp}-package, SBCL internals, or code where the
10 instrumenting overhead is excessive.
11
12 This module is known not to work consistently on the Alpha platform,
13 for technical reasons related to the implementation of a machine
14 language idiom for marking sections of code to be treated as atomic by
15 the garbage collector;  However, it should work on other platforms,
16 and the deficiency on the Alpha will eventually be rectified.
17
18 @subsection Example Usage
19
20 @lisp
21 (require :sb-sprof)
22 (sb-sprof:start-profiling)
23
24 (defvar *a* 0)
25 (dotimes (i (expt 2 26))
26   (setf *a* (logxor *a* (* i 5)
27                     (+ *a* i))))
28
29 (sb-sprof:stop-profiling)
30 (sb-sprof:report)
31 @end lisp
32
33 The profiler hooks into the disassembler such that instructions which
34 have been sampled are annotated with their relative frequency of
35 sampling.  This information is not stored across different sampling
36 runs. @c FIXME: maybe it should be?
37
38 @subsection Functions
39
40 @include fun-sb-sprof-report.texinfo
41
42 @include fun-sb-sprof-reset.texinfo
43
44 @include fun-sb-sprof-start-profiling.texinfo
45
46 @include fun-sb-sprof-stop-profiling.texinfo
47
48 @subsection Macros
49
50 @include macro-sb-sprof-with-profiling.texinfo
51
52 @subsection Variables
53
54 @include var-sb-sprof-star-max-samples-star.texinfo
55
56 @include var-sb-sprof-star-sample-interval-star.texinfo
57    
58 @subsection Credits
59
60 @code{sb-sprof} is an SBCL port, with enhancements, of Gerd
61 Moellmann's statistical profiler for CMUCL.