| 1 |
#! stap -p4 |
| 2 |
# Copyright (C) 2012 Red Hat, Inc. |
| 3 |
# by William Cohen <[email protected]> |
| 4 |
# |
| 5 |
# exercise the stopwatch tapset |
| 6 |
|
| 7 |
probe begin |
| 8 |
{ |
| 9 |
start_stopwatch("wall"); |
| 10 |
/* The following assumes that target starts in user space */ |
| 11 |
/* If the target is already running and in the kernel, it is wrong. */ |
| 12 |
start_stopwatch("user"); |
| 13 |
stop_stopwatch("system") |
| 14 |
} |
| 15 |
|
| 16 |
probe syscall.* |
| 17 |
{ |
| 18 |
if (pid() != target()) next |
| 19 |
stop_stopwatch("user") |
| 20 |
start_stopwatch("system") |
| 21 |
} |
| 22 |
|
| 23 |
probe syscall.*.return |
| 24 |
{ |
| 25 |
if (pid() != target()) next |
| 26 |
start_stopwatch("user") |
| 27 |
stop_stopwatch("system") |
| 28 |
} |
| 29 |
|
| 30 |
probe end |
| 31 |
{ |
| 32 |
stop_stopwatch("wall") |
| 33 |
stop_stopwatch("user") |
| 34 |
stop_stopwatch("system") |
| 35 |
|
| 36 |
w = read_stopwatch_s("wall") |
| 37 |
u = read_stopwatch_s("user") |
| 38 |
s = read_stopwatch_s("system") |
| 39 |
printf ("real\t%6ds\n", w); |
| 40 |
printf ("user\t%6ds\n", u); |
| 41 |
printf ("sys\t%6ds\n", s); |
| 42 |
|
| 43 |
w = read_stopwatch_ms("wall") |
| 44 |
u = read_stopwatch_ms("user") |
| 45 |
s = read_stopwatch_ms("system") |
| 46 |
printf ("real\t%9dms\n", w); |
| 47 |
printf ("user\t%9dms\n", u); |
| 48 |
printf ("sys\t%9dms\n", s); |
| 49 |
|
| 50 |
w = read_stopwatch_us("wall") |
| 51 |
u = read_stopwatch_us("user") |
| 52 |
s = read_stopwatch_us("system") |
| 53 |
printf ("real\t%12dus\n", w); |
| 54 |
printf ("user\t%12dus\n", u); |
| 55 |
printf ("sys\t%12dus\n", s); |
| 56 |
|
| 57 |
w = read_stopwatch_ns("wall") |
| 58 |
u = read_stopwatch_ns("user") |
| 59 |
s = read_stopwatch_ns("system") |
| 60 |
printf ("real\t%15dns\n", w); |
| 61 |
printf ("user\t%15dns\n", u); |
| 62 |
printf ("sys\t%15dns\n", s); |
| 63 |
|
| 64 |
delete_stopwatch("wall") |
| 65 |
delete_stopwatch("user") |
| 66 |
delete_stopwatch("system") |
| 67 |
} |