-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathiointervals.stp
38 lines (32 loc) · 1.03 KB
/
iointervals.stp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env stap
# iointervals.stp
# Track time intervals for a subset of kernel
# functions. Based on func_time_stats.stp.
global startcall, intervals
# apply multiple probe points when the call enter:
probe syscall.open, syscall.close ,
syscall.read, syscall.write
{
startcall[name, tid()] = gettimeofday_us()
}
# when the call return, calculate the intervals:
probe syscall.open.return, syscall.close.return,
syscall.read.return, syscall.write.return
{
t = gettimeofday_us()
old_t = startcall[name, tid()]
if (old_t) intervals[name] <<< t - old_t
delete startcall[name, tid()]
}
probe begin {
printf("Collecting data... press Ctrl-C to stop.\n")
}
# when terminal the running, display the infomation.
probe end {
foreach (name in intervals) {
printf("intervals for %s -- min:%dus avg:%dus max:%dus count:%d\n",
name, @min(intervals[name]), @avg(intervals[name]),
@max(intervals[name]), @count(intervals[name]))
print(@hist_log(intervals[name]))
}
}