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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/env stap
global timebyfunc, topave, topcnt
global start
probe begin {
printf("Collecting data...\n")
}
probe module("ext3").function("*@fs/ext3/*")
{
start[probefunc(), tid()] = gettimeofday_ns()
}
probe module("ext3").function("*@fs/ext3/*").return
{
if (!([probefunc(), tid()] in start)) next
delta = gettimeofday_ns() - start[probefunc(), tid()]
timebyfunc[probefunc()] <<< delta
delete start[probefunc(), tid()]
}
function print_header() {
printf("%-26s %10s %12s %12s %12s %12s\n",
"Call", "Count", "Total ns",
"Avg ns", "Min ns", "Max ns")
}
probe end {
print_header()
foreach (call in timebyfunc)
topave[call] = @avg(timebyfunc[call])
foreach (call in timebyfunc)
topcnt[call] = @count(timebyfunc[call])
foreach (call in topcnt- )
printf("%-26s %10d %12d %12d %12d %12d\n", call,
@count(timebyfunc[call]),
@sum(timebyfunc[call]),
@avg(timebyfunc[call]),
@min(timebyfunc[call]),
@max(timebyfunc[call]))
//foreach (call in timebyfunc)
// printf("%-26s %10d %12d %12d %12d %12d\n", call,
// @count(timebyfunc[call]),
// @sum(timebyfunc[call]),
// @avg(timebyfunc[call]),
// @min(timebyfunc[call]),
// @max(timebyfunc[call]))
delete timebyfunc
}
|