summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/profiler/profiler.man
blob: 1737264e9487f766ba28c5c155ee3211262b343d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin profiler n 0.3]
[keywords performance]
[keywords profile]
[keywords speed]
[moddesc   {Tcl Profiler}]
[titledesc {Tcl source code profiler}]
[category  {Programming tools}]
[require Tcl 8.3]
[require profiler [opt 0.3]]
[description]
[para]

The [package profiler] package provides a simple Tcl source code
profiler.  It is a function-level profiler; that is, it collects only
function-level information, not the more detailed line-level
information.  It operates by redefining the Tcl [cmd proc] command.
Profiling is initiated via the [cmd ::profiler::init] command.

[section COMMANDS]

[list_begin definitions]

[call [cmd ::profiler::init]]

Initiate profiling.  All procedures created after this command is
called will be profiled.  To profile an entire application, this
command must be called before any other commands.

[call [cmd ::profiler::dump] [arg pattern]]

Dump profiling information for the all functions matching

[arg pattern].  If no pattern is specified, information for all
functions will be returned.  The result is a list of key/value pairs
that maps function names to information about that function.  The
information about each function is in turn a list of key/value pairs.
The keys used and their values are:

[list_begin definitions]

[def [const totalCalls]]

The total number of times [arg functionName] was called.

[def [const callerDist]]

A list of key/value pairs mapping each calling function that called
[arg functionName] to the number of times it called

[arg functionName].

[def [const compileTime]]

The runtime, in clock clicks, of [arg functionName] the first time
that it was called.

[def [const totalRuntime]]

The sum of the runtimes of all calls of [arg functionName].

[def [const averageRuntime]]

Average runtime of [arg functionName].

[def [const descendantTime]]

Sum of the time spent in descendants of [arg functionName].

[def [const averageDescendantTime]]

Average time spent in descendants of [arg functionName].

[list_end]

[call [cmd ::profiler::print] [opt [arg pattern]]]

Print profiling information for all functions matching [arg pattern].
If no pattern is specified, information about all functions will be
displayed.  The return result is a human readable display of the
profiling information.

[call [cmd ::profiler::reset] [opt [arg pattern]]]

Reset profiling information for all functions matching [arg pattern].
If no pattern is specified, information will be reset for all
functions.

[call [cmd ::profiler::suspend] [opt [arg pattern]]]

Suspend profiling for all functions matching [arg pattern].  If no
pattern is specified, profiling will be suspended for all
functions. It stops gathering profiling information after this command
is issued. However, it does not erase any profiling information that
has been gathered previously.  Use resume command to re-enable
profiling.

[call [cmd ::profiler::resume] [opt [arg pattern]]]

Resume profiling for all functions matching [arg pattern].  If no
pattern is specified, profiling will be resumed for all functions.
This command should be invoked after suspending the profiler in the
code.

[call [cmd ::profiler::sortFunctions] [arg key]]

Return a list of functions sorted by a particular profiling statistic.
Supported values for [arg key] are: [const calls],

[const exclusiveTime], [const compileTime], [const nonCompileTime],
[const totalRuntime], [const avgExclusiveTime], and

[const avgRuntime].  The return result is a list of lists, where each
sublist consists of a function name and the value of [arg key] for
that function.

[list_end]

[vset CATEGORY profiler]
[include ../doctools2base/include/feedback.inc]
[manpage_end]