From 27d901a2c6bc2ad42449cbbdeac116509e6686a9 Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Mon, 15 Aug 2005 01:46:19 +0000 Subject: [PATCH] some example dtrace scripts --- maintenance/dtrace/counts.d | 23 +++++++++++++++++++++++ maintenance/dtrace/tree.d | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 maintenance/dtrace/counts.d create mode 100644 maintenance/dtrace/tree.d diff --git a/maintenance/dtrace/counts.d b/maintenance/dtrace/counts.d new file mode 100644 index 0000000000..bedb454736 --- /dev/null +++ b/maintenance/dtrace/counts.d @@ -0,0 +1,23 @@ +/* + * This software is in the public domain. + * + * $Id$ + */ + +#pragma D option quiet + +self int tottime; +BEGIN { + tottime = timestamp; +} + +php$target:::function-entry + @counts[copyinstr(arg0)] = count(); +} + +END { + printf("Total time: %dus\n", (timestamp - tottime) / 1000); + printf("# calls by function:\n"); + printa("%-40s %@d\n", @counts); +} + diff --git a/maintenance/dtrace/tree.d b/maintenance/dtrace/tree.d new file mode 100644 index 0000000000..a799cb12fc --- /dev/null +++ b/maintenance/dtrace/tree.d @@ -0,0 +1,26 @@ +/* + * This software is in the public domain. + * + * $Id$ + */ + +#pragma D option quiet + +self int indent; +self int times[int]; + +php$target:::function-entry +{ + @counts[copyinstr(arg0)] = count(); + printf("%*s", self->indent, ""); + printf("-> %s\n", copyinstr(arg0)); + self->times[self->indent] = timestamp; + self->indent += 2; +} + +php$target:::function-return +{ + self->indent -= 2; + printf("%*s", self->indent, ""); + printf("<- %s %dus\n", copyinstr(arg0), (timestamp - self->times[self->indent]) / 1000); +} -- 2.20.1