Tcl Source Code

Check-in [9a8fb66857]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:re-integrates the changes from the TIP#527 description into the manpage
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sebres-8-5-timerate
Files: files | file ages | folders
SHA3-256: 9a8fb668571b775c6e38beff319bc59d4d117c4dd7ba957f8e70e2db348c9b60
User & Date: sebres 2019-03-04 20:39:09.589
Context
2019-03-04
20:40
tools/tcltk-man2html: html-code for micro (sec) character check-in: a9f85173d9 user: sebres tags: sebres-8-5-timerate
20:39
re-integrates the changes from the TIP#527 description into the manpage check-in: 9a8fb66857 user: sebres tags: sebres-8-5-timerate
2019-02-13
01:22
timerate documentation extended check-in: af42c485d8 user: sebres tags: sebres-8-5-timerate
Changes
Unified Diff Ignore Whitespace Patch
Changes to doc/timerate.n.
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
.BE
.SH DESCRIPTION
.PP
The first and second form will evaluate \fIscript\fR until the interval
\fItime\fR given in milliseconds elapses, or for 1000 milliseconds (1 second)
if \fItime\fR is not specified.
.sp


If \fImax-count\fR is specified, it imposes a further restriction by the maximal 
number of iterations.
.sp
It will then return a canonical tcl-list of the form
.PP
.CS
\f0.095977 ยตs/# 52095836 # 10419167 #/sec 5000.000 nett-ms\fR
.CE
.PP
which indicates:
.IP \(bu
the average amount of time required per iteration, in microseconds (lindex $result 0)
.IP \(bu
the count how many times it was executed (lindex $result 2)
.IP \(bu
the estimated rate per second (lindex $result 4)
.IP \(bu
the estimated real execution time without measurement overhead (lindex $result 6)
.PP
Time is measured in elapsed time using heighest timer resolution as possible, not CPU time.

This command may be used to provide information as to how well the script or a tcl-command 
is performing and can help determine bottlenecks and fine-tune application performance.

.PP
\fI-calibrate\fR
.
To measure very fast scripts as exact as posible the calibration process
may be required.

This parameter used to calibrate \fBtimerate\fR calculating the estimated overhead 
of given \fIscript\fR as default overhead for further execution of \fBtimerate\fR.

It can take up to 10 seconds if parameter \fItime\fR is not specified.
.PP
\fI-overhead double\fR
.

This parameter used to supply the measurement overhead of single iteration 
(in microseconds) that should be ignored during whole evaluation process.

.PP
\fI-direct\fR
.
Causes direct execution per iteration (not compiled variant of evaluation used).



.PP
In opposition to \fBtime\fR the execution limited here by fixed time instead of 
repetition count.

Additionally the compiled variant of the script will be used during whole evaluation 
(as if it were part of a compiled \fBproc\fR), if parameter \fI-direct\fR is not specified.

Therefore it provides more precise results and prevents very long execution time 
by slow scripts resp. scripts with unknown speed.


.SH EXAMPLE
Estimate how fast it takes for a simple Tcl \fBfor\fR loop (including
operations on variable \fIi\fR) to count to a ten:
.PP
.CS
# calibrate:
timerate -calibrate {}
# measure:
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
.CE
.PP
Estimate how fast it takes for a simple Tcl \fBfor\fR loop only (ignoring the 
overhead for operations on variable \fIi\fR) to count to a ten:

.PP
.CS
# calibrate for overhead of variable operations:
set i 0; timerate -calibrate {expr {$i<10}; incr i} 1000
# measure:
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
.CE
.PP
Estimate the rate of calculating the hour using \fBclock format\fR only, ignoring 
overhead of the rest, without measurement how fast it takes for a whole script:

.PP
.CS
# calibrate:
timerate -calibrate {}
# estimate overhead:
set tm 0
set ovh [lindex [timerate { incr tm [expr {24*60*60}] }] 0]







>
>
|
|




|












|
>
|
|
>
|





|
|
>
|
|


>
|
<
>
|


|
>
>
>

|
<
>
|
|
>
|
<
>












|
|
>








|
|
>







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
.BE
.SH DESCRIPTION
.PP
The first and second form will evaluate \fIscript\fR until the interval
\fItime\fR given in milliseconds elapses, or for 1000 milliseconds (1 second)
if \fItime\fR is not specified.
.sp
The parameter \fImax-count\fR could additionally impose a further restriction
by the maximal number of iterations to evaluate the script.
If \fImax-count\fR is specified, the evalution will stop either this count of
iterations is reached or the time is exceeded.
.sp
It will then return a canonical tcl-list of the form
.PP
.CS
\fB0.095977 \(mcs/# 52095836 # 10419167 #/sec 5000.000 nett-ms\fR
.CE
.PP
which indicates:
.IP \(bu
the average amount of time required per iteration, in microseconds (lindex $result 0)
.IP \(bu
the count how many times it was executed (lindex $result 2)
.IP \(bu
the estimated rate per second (lindex $result 4)
.IP \(bu
the estimated real execution time without measurement overhead (lindex $result 6)
.PP
Time is measured in elapsed time using the finest timer resolution as possible,
not CPU time.
This command may be used to provide information as to how well the script or a
tcl-command is performing and can help determine bottlenecks and fine-tune
application performance.
.TP
\fI-calibrate\fR
.
To measure very fast scripts as exact as posible the calibration process
may be required.

The \fI-calibrate\fR option is used to calibrate timerate, calculating the
estimated overhead of the given script as the default overhead for future 
invocations of the \fBtimerate\fR command. If the \fItime\fR parameter is not 
specified, the calibrate procedure runs for up to 10 seconds.
.TP
\fI-overhead double\fR
.
The \fI-overhead\fR parameter supplies an estimate (in microseconds) of the
measurement overhead of each iteration of the tested script. This quantity

will be subtracted from the measured time prior to reporting results.
.TP
\fI-direct\fR
.
The \fI-direct\fR option causes direct execution of the supplied script,
without compilation, in a manner similar to the \fBtime\fR command. It can be
used to measure the cost of \fBTcl_EvalObjEx\fR, of the invocation of canonical
lists, and of the uncompiled versions of bytecoded commands.
.PP
As opposed to the \fBtime\fR commmand, which runs the tested script for a fixed

number of iterations, the timerate command runs it for a fixed time.
Additionally, the compiled variant of the script will be used during the entire
measurement, as if the script were part of a compiled procedure, if the \fI-direct\fR
option is not specified. The fixed time period and possibility of compilation allow
for more precise results and prevent very long execution times by slow scripts, making

it practical for measuring scripts with highly uncertain execution times.

.SH EXAMPLE
Estimate how fast it takes for a simple Tcl \fBfor\fR loop (including
operations on variable \fIi\fR) to count to a ten:
.PP
.CS
# calibrate:
timerate -calibrate {}
# measure:
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
.CE
.PP
Estimate how fast it takes for a simple Tcl \fBfor\fR loop, ignoring the
overhead for to perform ten iterations, ignoring the overhead of the management
of the variable that controls the loop:
.PP
.CS
# calibrate for overhead of variable operations:
set i 0; timerate -calibrate {expr {$i<10}; incr i} 1000
# measure:
timerate { for {set i 0} {$i<10} {incr i} {} } 5000
.CE
.PP
Estimate the speed of calculating the hour of the day using \fBclock format\fR only,
ignoring overhead of the portion of the script that prepares the time for it to
calculate:
.PP
.CS
# calibrate:
timerate -calibrate {}
# estimate overhead:
set tm 0
set ovh [lindex [timerate { incr tm [expr {24*60*60}] }] 0]