set-up-profiler &key symbols packages kind interval limit cutoff collapse style gc call-counter show-unknown-frames kw-contexts subfunctions
A symbol or a list of symbols.
A valid package name, or a list of package names, :none
or :all
.
:profile
, :virtual
or :real
.
An integer greater than or equal to 10000.
An integer or nil
.
An integer or nil
.
A generalized boolean.
:tree
, :list
or nil
.
A generalized boolean.
A generalized boolean.
t
or a list of KnowledgeWorks context names.
A boolean.
set-up-profiler
is used to declare the values of the parameters of the profiling function.
packages specifies that the symbols in these packages should be monitored, that is added to *profile-symbol-list*. If packages is :all
, then symbols in all packages are monitored. If packages is :none
, then no package is used to find symbols to monitor. Otherwise, packages should be a list of package specifiers, and the symbols in these packages are monitored.
If symbols is non-nil, it should be a list of function-dspecs to monitor in addition to the symbols that were specified by packages. These are typically symbols, but can be other functions as specified in Function dspecs.
Note: When a symbol that names a generic function should be monitored, LispWorks adds all the methods of the generic function to the profile list.
If both packages and symbols are nil
, then set-up-profiler
behaves as if packages is :all
. Thus if you actually want to monitor no symbols, you need to pass :packages :none
. That is useful if you want to monitor only KnowledgeWorks rules (see kw-contexts below).
kind specifies the way that the time between samples is measured on Unix-like platforms:
Process time only.
Process time and system time for the process.
Real time.
The default value of kind is :profile
.
Note: kind is ignored on Microsoft Windows platforms.
interval specifies the interval in microseconds between profile samples. The minimum value of interval is 10000, that is 10 ms. The default value of interval is 10000.
limit, when non-nil, sets *default-profiler-limit*. This limits the maximum number of lines printed in the profile output (not including the tree). The default value is 100.
cutoff, when non-nil, sets *default-profiler-cutoff*. This is the default minimum percentage that the profiler will display in the output tree. Functions below this percentage will not be displayed. The default is nil
, that is there is no cutoff.
collapse specifies whether functions with only one callee in the profile tree should be collapsed, that is, only the child is printed. When passed, sets *default-profiler-collapse*. The default value of collapse is nil
.
style controls the format of output. If style is not passed or passed as nil
, the format does not change. If style is passed, it can take these values:
The profiler will show the functions seen on the stack.
The profiler will generate a tree of calls seen in the profiler, as well as the output shown by :list
.
The default value of style is :tree
.
gc specifies whether to profile functions inside the memory management code (more accurately, functions that are called on the GC stack) in addition to any other profiling. The default value of gc is nil
.
call-counter specifies whether to add extra code to count calls. The counting is done dynamically. If call-counter is nil
, call counters are not added, and the call counter of all functions is displayed as 0. The default value of call-counter is nil
in SMP LispWorks and t
in non-SMP LispWorks. This is because the counting significantly affects the performance of applications using Symmetric Multiprocessing (SMP).
show-unknown-frames controls whether the profile tree shows nodes where the name of the function is unknown. The default value of show-unknown-frames is nil
.
kw-contexts allows you to profile forward chaining rules in KnowledgeWorks (see the
KnowledgeWorks and Prolog User Guide
). When kw-contexts is t
(the default), all context are profiled. Otherwise it should be a list of context names. The profiler profiles all the forward rules in each context.
subfunctions controls whether to profile subfunctions of the functions that are profiled. When it is non-nil, for each function that the profiler is profiling, the profiler checks if it has subfunctions, and if it has then it profiles them too. The default value of subfunctions is nil
.
If subfunctions is non-nil then initializing the profiler is somewhat slower, and also, because the names of subfunctions are long, the output is more messy. It is sometimes useful though.
set-up-profiler
, it calls set-up-profiler
implicitly without any arguments. That means it will monitor all symbols in the image, and if KnowledgeWorks is loaded also all forward chaining rules. In most cases this is a useful behavior, so it is not necessary to use set-up-profiler
.set-up-profiler
finds all the symbols in the specified packages at the time it is called. Thus symbols that are give function definitions after the call to set-up-profiler
are not profiled, whether or not they are in packages that were passed to set-up-profiler
. If you want to ensure that all symbols are profiled, you need to call set-up-profiler
just before invoking the profiler.nil
. However, in most cases the profiler is used to find bottlenecks where the slowdown is hundreds of percentage points and so the effect of call counting is less significant.debug
is greater than 0 at compile-time, and call-counter has no effect.
(set-up-profiler :packages '(my-package common-lisp))
(set-up-profiler :symbols
(my-list-all-interesting-functions))
*default-profiler-collapse*
*default-profiler-cutoff*
*default-profiler-limit*
profile
start-profiling
stop-profiling
The Profiler
LispWorks User Guide and Reference Manual - 20 Sep 2017