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