3 * js_calldist.d - measure JavaScript elapsed times for types of operation.
4 * Written for the JavaScript DTrace provider.
6 * $Id: js_calldist.d 63 2007-10-04 04:34:38Z brendan $
8 * This traces JavaScript activity from all browsers running on the system with
9 * JavaScript provider support.
11 * USAGE: js_calldist.d # hit Ctrl-C to end
14 * 1 Filename of the JavaScript program
15 * 2 Type of call (func/obj-new)
18 * Filename and function names are printed if available.
20 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
24 * The contents of this file are subject to the terms of the
25 * Common Development and Distribution License, Version 1.0 only
26 * (the "License"). You may not use this file except in compliance
29 * You can obtain a copy of the license at Docs/cddl1.txt
30 * or http://www.opensolaris.org/os/licensing.
31 * See the License for the specific language governing permissions
32 * and limitations under the License.
36 * 09-Sep-2007 Brendan Gregg Created this.
39 #pragma D option quiet
43 printf("Tracing... Hit Ctrl-C to end.\n");
46 javascript*:::function-entry
49 self->exclude[self->depth] = 0;
50 self->function[self->depth] = timestamp;
53 javascript*:::function-return
54 /self->function[self->depth]/
56 this->elapsed_incl = timestamp - self->function[self->depth];
57 this->elapsed_excl = this->elapsed_incl - self->exclude[self->depth];
58 self->function[self->depth] = 0;
59 self->exclude[self->depth] = 0;
60 this->file = basename(copyinstr(arg0));
61 this->name = copyinstr(arg2);
63 @types_incl[this->file, "func", this->name] =
64 quantize(this->elapsed_incl / 1000);
65 @types_excl[this->file, "func", this->name] =
66 quantize(this->elapsed_excl / 1000);
69 self->exclude[self->depth] += this->elapsed_incl;
72 javascript*:::object-create-start
74 self->object = timestamp;
77 javascript*:::object-create-done
80 this->elapsed = timestamp - self->object;
82 this->file = basename(copyinstr(arg0));
83 this->name = copyinstr(arg1);
85 @types[this->file, "obj-new", this->name] =
86 quantize(this->elapsed / 1000);
88 self->exclude[self->depth] += this->elapsed;
93 printf("\nElapsed times (us),\n");
94 printa(" %s, %s, %s %@d\n", @types);
96 printf("\nExclusive function elapsed times (us),\n");
97 printa(" %s, %s, %s %@d\n", @types_excl);
99 printf("\nInclusive function elapsed times (us),\n");
100 printa(" %s, %s, %s %@d\n", @types_incl);