xref: /netbsd-src/external/cddl/dtracetoolkit/dist/JavaScript/js_objcpu.d (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1*c29d5175Schristos #!/usr/sbin/dtrace -Zs
2*c29d5175Schristos /*
3*c29d5175Schristos  * js_objcpu.d - measure JavaScript object creation on-CPU time using DTrace.
4*c29d5175Schristos  *               Written for the JavaScript DTrace provider.
5*c29d5175Schristos  *
6*c29d5175Schristos  * $Id: js_objcpu.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
7*c29d5175Schristos  *
8*c29d5175Schristos  * This traces JavaScript activity from all browsers running on the system
9*c29d5175Schristos  * with JavaScript provider support.
10*c29d5175Schristos  *
11*c29d5175Schristos  * USAGE: js_objcpu.d	 	# hit Ctrl-C to end
12*c29d5175Schristos  *
13*c29d5175Schristos  * Class names are printed if available.
14*c29d5175Schristos  *
15*c29d5175Schristos  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
16*c29d5175Schristos  *
17*c29d5175Schristos  * CDDL HEADER START
18*c29d5175Schristos  *
19*c29d5175Schristos  *  The contents of this file are subject to the terms of the
20*c29d5175Schristos  *  Common Development and Distribution License, Version 1.0 only
21*c29d5175Schristos  *  (the "License").  You may not use this file except in compliance
22*c29d5175Schristos  *  with the License.
23*c29d5175Schristos  *
24*c29d5175Schristos  *  You can obtain a copy of the license at Docs/cddl1.txt
25*c29d5175Schristos  *  or http://www.opensolaris.org/os/licensing.
26*c29d5175Schristos  *  See the License for the specific language governing permissions
27*c29d5175Schristos  *  and limitations under the License.
28*c29d5175Schristos  *
29*c29d5175Schristos  * CDDL HEADER END
30*c29d5175Schristos  *
31*c29d5175Schristos  * 09-Sep-2007	Brendan Gregg	Created this.
32*c29d5175Schristos  */
33*c29d5175Schristos 
34*c29d5175Schristos #pragma D option quiet
35*c29d5175Schristos 
36*c29d5175Schristos dtrace:::BEGIN
37*c29d5175Schristos {
38*c29d5175Schristos 	printf("Tracing... Hit Ctrl-C to end.\n");
39*c29d5175Schristos }
40*c29d5175Schristos 
41*c29d5175Schristos javascript*:::object-create-start
42*c29d5175Schristos {
43*c29d5175Schristos 	self->vstart = vtimestamp;
44*c29d5175Schristos }
45*c29d5175Schristos 
46*c29d5175Schristos javascript*:::object-create-done
47*c29d5175Schristos /self->vstart/
48*c29d5175Schristos {
49*c29d5175Schristos 	this->oncpu = vtimestamp - self->vstart;
50*c29d5175Schristos 	@total = sum(this->oncpu);
51*c29d5175Schristos 	@dist[copyinstr(arg1)] = quantize(this->oncpu / 1000);
52*c29d5175Schristos 	self->vstart = 0;
53*c29d5175Schristos }
54*c29d5175Schristos 
55*c29d5175Schristos dtrace:::END
56*c29d5175Schristos {
57*c29d5175Schristos 	normalize(@total, 1000000);
58*c29d5175Schristos 	printa("Total object creation on-CPU time (ms): %@d\n\n", @total);
59*c29d5175Schristos 	printf("Object creation on-CPU time distributions (us),\n");
60*c29d5175Schristos 	printa(@dist);
61*c29d5175Schristos }
62