1N/A#!/usr/sbin/dtrace -Zs
1N/A/*
1N/A * tcl_stat.d - Tcl operation stats using DTrace.
1N/A * Written for the Tcl DTrace provider.
1N/A *
1N/A * $Id: tcl_stat.d 63 2007-10-04 04:34:38Z brendan $
1N/A *
1N/A * This traces activity from all Tcl processes on the system with DTrace
1N/A * provider support (tcl8.4.16).
1N/A *
1N/A * USAGE: tcl_stat.d [interval [count]]
1N/A *
1N/A * FIELDS:
1N/A * EXEC/s Tcl programs executed per second, including
1N/A * those without Tcl provider support
1N/A * PROC/s Procedures called, per second
1N/A * CMD/s Commands created, per second
1N/A * OBJNEW/s Objects created, per second
1N/A * OBJFRE/s Objects freed, per second
1N/A * OP/s Bytecode operations, per second
1N/A *
1N/A * The numbers are counts for the interval specified. The default interval
1N/A * is 1 second.
1N/A *
1N/A * If you see a count in "EXECS" but not in the other columns, then you
1N/A * may have older Tcl software that does not have the integrated DTrace
1N/A * provider (or newer software where the provider has changed).
1N/A *
1N/A * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
1N/A *
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License, Version 1.0 only
1N/A * (the "License"). You may not use this file except in compliance
1N/A * with the License.
1N/A *
1N/A * You can obtain a copy of the license at Docs/cddl1.txt
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * CDDL HEADER END
1N/A *
1N/A * 09-Sep-2007 Brendan Gregg Created this.
1N/A */
1N/A
1N/A#pragma D option quiet
1N/A#pragma D option defaultargs
1N/A
1N/Ainline int SCREEN = 21;
1N/A
1N/Adtrace:::BEGIN
1N/A{
1N/A execs = procs = cmds = objnew = objfree = ops = 0;
1N/A lines = SCREEN + 1;
1N/A interval = $1 ? $1 : 1;
1N/A counts = $2 ? $2 : -1;
1N/A secs = interval;
1N/A first = 1;
1N/A}
1N/A
1N/Aprofile:::tick-1sec
1N/A{
1N/A secs--;
1N/A}
1N/A
1N/A/*
1N/A * Print Header
1N/A */
1N/Adtrace:::BEGIN,
1N/Aprofile:::tick-1sec
1N/A/first || (secs == 0 && lines > SCREEN)/
1N/A{
1N/A printf("%-20s %6s %8s %8s %8s %8s %8s\n", "TIME", "EXEC/s",
1N/A "PROC/s", "CMD/s", "OBJNEW/s", "OBJFRE/s", "OP/s");
1N/A lines = 0;
1N/A first = 0;
1N/A}
1N/A
1N/A/*
1N/A * Tally Data
1N/A */
1N/Aproc:::exec-success
1N/A/execname == "tcl" || execname == "tclsh"/
1N/A{
1N/A execs++;
1N/A}
1N/A
1N/Atcl*:::proc-entry
1N/A{
1N/A procs++;
1N/A}
1N/A
1N/Atcl*:::cmd-entry
1N/A{
1N/A cmds++;
1N/A}
1N/A
1N/Atcl*:::obj-create
1N/A{
1N/A objnew++;
1N/A}
1N/A
1N/Atcl*:::obj-free
1N/A{
1N/A objfree++;
1N/A}
1N/A
1N/Atcl*:::inst-start
1N/A{
1N/A ops++;
1N/A}
1N/A
1N/A/*
1N/A * Print Output
1N/A */
1N/Aprofile:::tick-1sec
1N/A/secs == 0/
1N/A{
1N/A printf("%-20Y %6d %8d %8d %8d %8d %8d\n", walltimestamp,
1N/A execs / interval, procs / interval, cmds / interval,
1N/A objnew / interval, objfree / interval, ops / interval);
1N/A execs = procs = cmds = objnew = objfree = ops = 0;
1N/A secs = interval;
1N/A lines++;
1N/A counts--;
1N/A}
1N/A
1N/A/*
1N/A * End
1N/A */
1N/Aprofile:::tick-1sec
1N/A/counts == 0/
1N/A{
1N/A exit(0);
1N/A}