-
Notifications
You must be signed in to change notification settings - Fork 0
/
strace_futexpoll_summary.py
executable file
·77 lines (63 loc) · 2.34 KB
/
strace_futexpoll_summary.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import sys
def get_pid_from_line(line):
return line.split()[0]
def get_time_from_line(line):
time_column = line.split()[-1]
time_string = time_column[1:-1]
return time_string
def main():
file = open(sys.argv[1], "r")
pid_futex_wait = []
pid_poll_wait = []
futex_wait_count = 0
futex_wait_time = 0
poll_count = 0
poll_wait_time = 0
line = file.readline()
while line != '':
try:
if "detached" in line:
pass
elif "FUTEX_WAIT" in line:
if "unfinished" in line:
pid_futex_wait.append(get_pid_from_line(line))
else:
futex_wait_count += 1
futex_wait_time += float(get_time_from_line(line))
elif "poll(" in line:
if "unfinished" in line:
pid_poll_wait.append(get_pid_from_line(line))
else:
poll_count += 1
poll_wait_time += float(get_time_from_line(line))
elif "futex resumed" in line:
pid = get_pid_from_line(line)
if pid in pid_futex_wait:
pid_futex_wait.remove(pid)
futex_wait_count += 1
futex_wait_time += float(get_time_from_line(line))
elif "poll resumed" in line:
pid = get_pid_from_line(line)
if pid in pid_poll_wait:
pid_poll_wait.remove(pid)
poll_count += 1
poll_wait_time += float(get_time_from_line(line))
except ValueError:
print(f"ERROR: {line}")
line = file.readline()
if futex_wait_count > 0:
print(" FUTEX:")
print("=======================")
print(f"Total count: {futex_wait_count}")
print(f"Total time spend witing: {futex_wait_time:.6f}")
print(f"Average wait time: {futex_wait_time/futex_wait_count:.6f}")
print("=======================")
if poll_count > 0:
print(" POLL:")
print("=======================")
print(f"Total count: {poll_count}")
print(f"Total time spend witing: {poll_wait_time:.6f}")
print(f"Average wait time: {poll_wait_time/poll_count:.6f}")
print("=======================")
if __name__ == "__main__":
main()