summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2008-06-12 17:53:05 -0400
committerWilliam Cohen <wcohen@redhat.com>2008-06-12 17:53:05 -0400
commit7b7fb26004f91f06cdbcb872d18e9e87e8708ad0 (patch)
treeb1278acde69691d829b80d2975514cf4c869d47a /testsuite
parent53c08c2f0a7a03f755d04f0fec7749a0e83d8b45 (diff)
downloadsystemtap-steved-7b7fb26004f91f06cdbcb872d18e9e87e8708ad0.tar.gz
systemtap-steved-7b7fb26004f91f06cdbcb872d18e9e87e8708ad0.tar.xz
systemtap-steved-7b7fb26004f91f06cdbcb872d18e9e87e8708ad0.zip
Add thread-times.meta and thread-times.stp.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/systemtap.examples/ChangeLog4
-rw-r--r--testsuite/systemtap.examples/thread-times.meta13
-rw-r--r--testsuite/systemtap.examples/thread-times.stp32
3 files changed, 49 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog
index 743e7adf..adaf2e03 100644
--- a/testsuite/systemtap.examples/ChangeLog
+++ b/testsuite/systemtap.examples/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-12 William Cohen <wcohen@redhat.com>
+
+ * thread-times.stp, thread-times.meta: New.
+
2008-05-20 William Cohen <wcohen@redhat.com>
* io_submit.stp, io_submit.meta:
diff --git a/testsuite/systemtap.examples/thread-times.meta b/testsuite/systemtap.examples/thread-times.meta
new file mode 100644
index 00000000..fcbf062e
--- /dev/null
+++ b/testsuite/systemtap.examples/thread-times.meta
@@ -0,0 +1,13 @@
+title: Profile kernel functions
+name: thread-times.stp
+version: 1.0
+author: anonymous
+keywords: profiling
+subsystem: kernel
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.
+test_check: stap -p4 thread-times.stp
+test_installcheck: stap thread-times.stp -c "sleep 1"
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
+}