3 * php_cpudist.d - measure PHP on-CPU times for functions.
4 * Written for the PHP DTrace provider.
6 * $Id: php_cpudist.d 53 2007-09-24 04:58:38Z brendan $
8 * This traces PHP activity from all programs running on the system with
9 * PHP provider support.
11 * USAGE: php_cpudist.d # hit Ctrl-C to end
13 * This script prints distribution plots of elapsed time for PHP
14 * operations. Use php_cputime.d for summary reports.
17 * 1 Filename of the PHP program
18 * 2 Type of call (func)
21 * Filename and function names are printed if available.
23 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
27 * The contents of this file are subject to the terms of the
28 * Common Development and Distribution License, Version 1.0 only
29 * (the "License"). You may not use this file except in compliance
32 * You can obtain a copy of the license at Docs/cddl1.txt
33 * or http://www.opensolaris.org/os/licensing.
34 * See the License for the specific language governing permissions
35 * and limitations under the License.
39 * 09-Sep-2007 Brendan Gregg Created this.
42 #pragma D option quiet
46 printf("Tracing... Hit Ctrl-C to end.\n");
53 self->exclude[self->depth] = 0;
54 self->function[self->depth] = vtimestamp;
57 php*:::function-return
58 /arg0 && self->function[self->depth]/
60 this->oncpu_incl = vtimestamp - self->function[self->depth];
61 this->oncpu_excl = this->oncpu_incl - self->exclude[self->depth];
62 self->function[self->depth] = 0;
63 self->exclude[self->depth] = 0;
64 this->file = basename(copyinstr(arg1));
65 this->name = copyinstr(arg0);
67 @types_incl[this->file, "func", this->name] =
68 quantize(this->oncpu_incl / 1000);
69 @types_excl[this->file, "func", this->name] =
70 quantize(this->oncpu_excl / 1000);
73 self->exclude[self->depth] += this->oncpu_incl;
78 printf("\nExclusive function on-CPU times (us),\n");
79 printa(" %s, %s, %s %@d\n", @types_excl);
81 printf("\nInclusive function on-CPU times (us),\n");
82 printa(" %s, %s, %s %@d\n", @types_incl);