Debian Codegraph @

testsuite/systemtap.examples/general/stopwatches.stp

raw
1 #! /usr/bin/env stap
2 # Copyright (C) 2012-2018 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 next two lines assumes that target is running and in user-space. */
11 start_stopwatch("user");
12 stop_stopwatch("system")
13 }
14
15 probe syscall_any
16 {
17 if (pid() != target()) next
18 stop_stopwatch("user")
19 start_stopwatch("system")
20 }
21
22 probe syscall_any.return
23 {
24 if (pid() != target()) next
25 start_stopwatch("user")
26 stop_stopwatch("system")
27 }
28
29 probe end
30 {
31 stop_stopwatch("wall")
32 stop_stopwatch("user")
33 stop_stopwatch("system")
34
35 w = read_stopwatch_us("wall")
36 u = read_stopwatch_us("user")
37 s = read_stopwatch_us("system")
38 printf ("wall clock %12dus\n", w);
39 printf ("wall clock in user-space %12dus\n", u);
40 printf ("wall clock in kernel-space %12dus\n", s);
41
42 delete_stopwatch("wall")
43 delete_stopwatch("user")
44 delete_stopwatch("system")
45 }