summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/profiling/fntimes.stp
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2010-02-02 08:28:16 -0500
committerDave Brolley <brolley@redhat.com>2010-02-02 08:28:16 -0500
commit743757687f9c09bf9ef84b576bc0aa0fc19dea4c (patch)
treebe77bd3f7d03be09774a25f7260182941e99907a /testsuite/systemtap.examples/profiling/fntimes.stp
parent241443ad36a5a2cacb9e8e6f12f808d304835f2a (diff)
parentcc57beca8d9d168ef42edb1f8b43f594105dfdf2 (diff)
downloadsystemtap-steved-743757687f9c09bf9ef84b576bc0aa0fc19dea4c.tar.gz
systemtap-steved-743757687f9c09bf9ef84b576bc0aa0fc19dea4c.tar.xz
systemtap-steved-743757687f9c09bf9ef84b576bc0aa0fc19dea4c.zip
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'testsuite/systemtap.examples/profiling/fntimes.stp')
-rwxr-xr-xtestsuite/systemtap.examples/profiling/fntimes.stp30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/profiling/fntimes.stp b/testsuite/systemtap.examples/profiling/fntimes.stp
new file mode 100755
index 00000000..e9daac77
--- /dev/null
+++ b/testsuite/systemtap.examples/profiling/fntimes.stp
@@ -0,0 +1,30 @@
+#! /usr/bin/stap
+
+# usage: fntimes.stp FUNCTIONPROBE
+# e.g. fntimes.stp 'module("ext4").function("*")'
+
+global mincount = 100 # training: beneath this number of hits, only collect data
+global note_percent = 250 # percent beyond maximum-so-far to generate report for
+function time() { return gettimeofday_us() } # time measurement function
+
+global times, entry
+
+probe $1.call {
+ entry[probefunc(),tid()] = time()
+}
+
+probe $1.return {
+ pf=probefunc()
+ tid=tid()
+ if ([pf,tid] in entry) { # seen function entry?
+ t = time()-entry[pf,tid] # t: elapsed time
+ delete entry[pf,tid]
+ if (@count(times[pf]) >= mincount
+ && t >= @max(times[pf]) * note_percent / 100) { # also consider @avg()
+ printf("function %s well over %s time (%d vs %d)\n",
+ pf, "maximum", t, @max(times[pf]))
+ # also consider: print_backtrace()
+ }
+ times[pf] <<< t # (increments @count, updates @max)
+ }
+}