summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2010-03-19 14:58:16 -0400
committerFrank Ch. Eigler <fche@elastic.org>2010-03-19 14:58:16 -0400
commitacd96f2fcdeaf29554e58d428626ca864590d2b4 (patch)
tree76f6fe1e8d433dca5e34863d9f4a6181b25da57d /testsuite
parent8890a74f7c6b71b0346f7fca8ce43674f706d247 (diff)
downloadsystemtap-steved-acd96f2fcdeaf29554e58d428626ca864590d2b4.tar.gz
systemtap-steved-acd96f2fcdeaf29554e58d428626ca864590d2b4.tar.xz
systemtap-steved-acd96f2fcdeaf29554e58d428626ca864590d2b4.zip
PR909: add a baby test case
* testsuite/systemtap.examples/profiling/thread-times.stp: Prefer perf.sw.cpu_clock to timer.profile. Prettify output by including comm string.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/systemtap.examples/profiling/thread-times.meta9
-rwxr-xr-xtestsuite/systemtap.examples/profiling/thread-times.stp26
2 files changed, 15 insertions, 20 deletions
diff --git a/testsuite/systemtap.examples/profiling/thread-times.meta b/testsuite/systemtap.examples/profiling/thread-times.meta
index 3cb3e93d..b7d37b1a 100644
--- a/testsuite/systemtap.examples/profiling/thread-times.meta
+++ b/testsuite/systemtap.examples/profiling/thread-times.meta
@@ -1,13 +1,6 @@
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.
+description: The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty threads occupying the CPUs, broken down as a percentage of user and kernel time.
test_check: stap -p4 thread-times.stp
test_installcheck: stap thread-times.stp -c "sleep 0.2"
diff --git a/testsuite/systemtap.examples/profiling/thread-times.stp b/testsuite/systemtap.examples/profiling/thread-times.stp
index cbe4118e..a75ffc5a 100755
--- a/testsuite/systemtap.examples/profiling/thread-times.stp
+++ b/testsuite/systemtap.examples/profiling/thread-times.stp
@@ -1,13 +1,15 @@
#! /usr/bin/stap
-probe timer.profile {
- tid=tid()
+probe perf.sw.cpu_clock!, timer.profile {
+ // NB: To avoid contention on SMP machines, no global scalars/arrays used,
+ // only contention-free statistics aggregates.
+ tid=tid(); e=execname()
if (!user_mode())
- kticks[tid] <<< 1
+ kticks[e,tid] <<< 1
else
- uticks[tid] <<< 1
+ uticks[e,tid] <<< 1
ticks <<< 1
- tids[tid] <<< 1
+ tids[e,tid] <<< 1
}
global uticks, kticks, ticks
@@ -16,13 +18,13 @@ 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 ("%16s %5s %7s %7s (of %d ticks)\n",
+ "comm", "tid", "%user", "%kernel", allticks)
+ foreach ([e,tid] in tids- limit 20) {
+ uscaled = @count(uticks[e,tid])*10000/allticks
+ kscaled = @count(kticks[e,tid])*10000/allticks
+ printf ("%16s %5d %3d.%02d%% %3d.%02d%%\n",
+ e, tid, uscaled/100, uscaled%100, kscaled/100, kscaled%100)
}
printf("\n")