1 #!/usr/sbin/dtrace -CZs
3 * tcl_calldist.d - measure Tcl elapsed time for different types of operation.
4 * Written for the Tcl DTrace provider.
6 * $Id: tcl_calldist.d 63 2007-10-04 04:34:38Z brendan $
8 * USAGE: tcl_calldist.d [top] # hit Ctrl-C to end
10 * tcl_calldist.d # default, truncate to 10 lines
11 * tcl_calldist.d 25 # truncate each report section to 25 lines
13 * This traces activity from all Tcl processes on the system with DTrace
14 * provider support (tcl8.4.16).
18 * 2 Type of call (proc/cmd/total)
21 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
25 * The contents of this file are subject to the terms of the
26 * Common Development and Distribution License, Version 1.0 only
27 * (the "License"). You may not use this file except in compliance
30 * You can obtain a copy of the license at Docs/cddl1.txt
31 * or http://www.opensolaris.org/os/licensing.
32 * See the License for the specific language governing permissions
33 * and limitations under the License.
37 * 09-Sep-2007 Brendan Gregg Created this.
40 #define TOP 10 /* default output truncation */
43 #pragma D option quiet
44 #pragma D option defaultargs
48 printf("Tracing... Hit Ctrl-C to end.\n");
49 top = $1 != 0 ? $1 : TOP;
55 self->exclude[self->depth] = 0;
56 self->proc[self->depth] = timestamp;
60 /self->proc[self->depth]/
62 this->elapsed_incl = timestamp - self->proc[self->depth];
63 this->elapsed_excl = this->elapsed_incl - self->exclude[self->depth];
64 self->proc[self->depth] = 0;
65 self->exclude[self->depth] = 0;
66 this->name = copyinstr(arg0);
68 @types_incl[pid, "proc", this->name] =
69 quantize(this->elapsed_incl / 1000);
70 @types_excl[pid, "proc", this->name] =
71 quantize(this->elapsed_excl / 1000);
74 self->exclude[self->depth] += this->elapsed_incl;
80 self->exclude[self->depth] = 0;
81 self->cmd[self->depth] = timestamp;
85 /self->cmd[self->depth]/
87 this->elapsed_incl = timestamp - self->cmd[self->depth];
88 this->elapsed_excl = this->elapsed_incl - self->exclude[self->depth];
89 self->cmd[self->depth] = 0;
90 self->exclude[self->depth] = 0;
91 this->name = copyinstr(arg0);
93 @types_incl[pid, "cmd", this->name] =
94 quantize(this->elapsed_incl / 1000);
95 @types_excl[pid, "cmd", this->name] =
96 quantize(this->elapsed_excl / 1000);
99 self->exclude[self->depth] += this->elapsed_incl;
104 trunc(@types_excl, top);
105 printf("\nTop %d exclusive elapsed times (us),\n", top);
106 printa(" PID=%d, %s, %s %@d\n", @types_excl);
108 trunc(@types_incl, top);
109 printf("\nTop %d inclusive elapsed times (us),\n", top);
110 printa(" PID=%d, %s, %s %@d\n", @types_incl);