Debian Codegraph @

testsuite/systemtap.examples/general/alias_suffixes.stp

raw
1 #!/usr/bin/env stap
2 # alias_suffixes.stp
3 # Uses alias suffixes to track time intervals for a subset of kernel
4 # functions. Based on func_time_stats.stp.
5
6 global start, intervals
7
8 # We can apply a suffix to multiple probe points designated by one alias:
9 probe miscellany = syscall.{open,close,read,write} { }
10
11 probe miscellany {
12 start[name, tid()] = gettimeofday_us()
13 }
14
15 # The 'return' suffix is passed on to each of the underlying probe points:
16 probe miscellany.return {
17 t = gettimeofday_us(); old_t = start[name, tid()]
18 if (old_t) intervals[name] <<< t - old_t
19 delete start[name, tid()]
20 }
21
22 probe begin {
23 printf("Collecting data... press Ctrl-C to stop.\n")
24 }
25
26 probe end {
27 foreach (name in intervals) {
28 printf("intervals for %s -- min:%dus avg:%dus max:%dus count:%d variance:%d\n",
29 name, @min(intervals[name]), @avg(intervals[name]),
30 @max(intervals[name]), @count(intervals[name]), @variance(intervals[name], 3))
31 print(@hist_log(intervals[name]))
32 }
33 }