blob: 986be65ef2a89f0872bd6d23f554f9dd117e739b (
plain)
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
|
#!/usr/bin/env stap
# This is an example of profiling a specific command or pid.
# It works by recording the time when a system call is entered
# exited.
# Usage: prof.stp -c "top -n5"
# Will start up "top" and after 5 iterations, will exit.
#
# Usage: prof.stp -x 3323
# Will profile pid 3323 until it ^c is hit.
#
probe kernel.function("sys_*") {
if (target() == tid())
calltime[tid()] = gettimeofday_us()
}
probe kernel.function("sys_*").return {
if (target() != tid()) next
now = gettimeofday_us()
c = calltime[tid()]
if (!c) next
ttime[probefunc()] <<< now - c
delete calltime[tid()]
}
probe end {
printf("\n")
foreach (x in ttime)
printf("%-20s\tcalls:%6d\tavg time (ms):%5d\ttotal(ms):%7d\n",
x, @count(ttime[x]), @avg(ttime[x]), @sum(ttime[x]))
}
global calltime, ttime
|