diff options
Diffstat (limited to 'testsuite/systemtap.examples/profiling/thread-times.stp')
-rwxr-xr-x | testsuite/systemtap.examples/profiling/thread-times.stp | 26 |
1 files changed, 14 insertions, 12 deletions
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") |