js_flowtime.d revision 1
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#!/usr/sbin/dtrace -Zs
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * js_flowtime.d - JavaScript function flow with delta times using DTrace.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Written for the JavaScript DTrace provider.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * $Id: js_flowtime.d 63 2007-10-04 04:34:38Z brendan $
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * This traces activity from all browsers on the system that are running
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * with JavaScript provider support.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * USAGE: js_flowtime.d # hit Ctrl-C to end
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * FIELDS:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * C CPU-id
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * TIME(us) Time since boot, us
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * FILE Filename that this function belongs to
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * DELTA(us) Elapsed time from previous line to this line
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * FUNC Function name
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * LEGEND:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * -> function entry
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * <- function return
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Filename and function names are printed if available.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * WARNING: Watch the first column carefully, it prints the CPU-id. If it
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * changes, then it is very likely that the output has been shuffled.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Common Development and Distribution License, Version 1.0 only
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * (the "License"). You may not use this file except in compliance
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You can obtain a copy of the license at Docs/cddl1.txt
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * or http://www.opensolaris.org/os/licensing.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * 09-Sep-2007 Brendan Gregg Created this.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option quiet
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option switchrate=10
self int depth;
dtrace:::BEGIN
{
printf("%3s %-16s %-18s %9s -- %s\n", "C", "TIME(us)", "FILE",
"DELTA(us)", "FUNC");
}
javascript*:::function-entry,
javascript*:::function-return
/self->last == 0/
{
self->last = timestamp;
}
javascript*:::function-entry
{
this->delta = (timestamp - self->last) / 1000;
printf("%3d %-16d %-18s %9d %*s-> %s\n", cpu, timestamp / 1000,
basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
copyinstr(arg2));
self->depth++;
self->last = timestamp;
}
javascript*:::function-return
{
this->delta = (timestamp - self->last) / 1000;
self->depth -= self->depth > 0 ? 1 : 0;
printf("%3d %-16d %-18s %9d %*s<- %s\n", cpu, timestamp / 1000,
basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
copyinstr(arg2));
self->last = timestamp;
}