summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/thread-times.stp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.examples/thread-times.stp')
-rw-r--r--testsuite/systemtap.examples/thread-times.stp32
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/thread-times.stp b/testsuite/systemtap.examples/thread-times.stp
new file mode 100644
index 00000000..1aeb2037
--- /dev/null
+++ b/testsuite/systemtap.examples/thread-times.stp
@@ -0,0 +1,32 @@
+#! /usr/bin/stap
+
+probe timer.profile {
+ tid=tid()
+ if (!user_mode())
+ kticks[tid] <<< 1
+ else
+ uticks[tid] <<< 1
+ ticks <<< 1
+ tids[tid] <<< 1
+}
+
+global uticks, kticks, ticks
+
+global tids
+
+probe timer.s(5), end {
+ allticks = @count(ticks)
+ printf ("%5s %7s %7s (of %d ticks)\n", "tid", "%user", "%kernel", allticks)
+ foreach (tid in tids- limit 20) {
+ uscaled = @count(uticks[tid])*10000/allticks
+ kscaled = @count(kticks[tid])*10000/allticks
+ printf ("%5d %3d.%02d%% %3d.%02d%%\n",
+ tid, uscaled/100, uscaled%100, kscaled/100, kscaled%100)
+ }
+ printf("\n")
+
+ delete uticks
+ delete kticks
+ delete ticks
+ delete tids
+}