hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/tools/perf/scripts/python/syscall-counts.py
....@@ -5,6 +5,8 @@
55 # Displays system-wide system call totals, broken down by syscall.
66 # If a [comm] arg is specified, only syscalls called by [comm] are displayed.
77
8
+from __future__ import print_function
9
+
810 import os
911 import sys
1012
....@@ -28,14 +30,14 @@
2830 syscalls = autodict()
2931
3032 def trace_begin():
31
- print "Press control+C to stop and show the summary"
33
+ print("Press control+C to stop and show the summary")
3234
3335 def trace_end():
3436 print_syscall_totals()
3537
3638 def raw_syscalls__sys_enter(event_name, context, common_cpu,
37
- common_secs, common_nsecs, common_pid, common_comm,
38
- common_callchain, id, args):
39
+ common_secs, common_nsecs, common_pid, common_comm,
40
+ common_callchain, id, args):
3941 if for_comm is not None:
4042 if common_comm != for_comm:
4143 return
....@@ -45,20 +47,19 @@
4547 syscalls[id] = 1
4648
4749 def syscalls__sys_enter(event_name, context, common_cpu,
48
- common_secs, common_nsecs, common_pid, common_comm,
49
- id, args):
50
+ common_secs, common_nsecs, common_pid, common_comm, id, args):
5051 raw_syscalls__sys_enter(**locals())
5152
5253 def print_syscall_totals():
53
- if for_comm is not None:
54
- print "\nsyscall events for %s:\n\n" % (for_comm),
55
- else:
56
- print "\nsyscall events:\n\n",
54
+ if for_comm is not None:
55
+ print("\nsyscall events for %s:\n" % (for_comm))
56
+ else:
57
+ print("\nsyscall events:\n")
5758
58
- print "%-40s %10s\n" % ("event", "count"),
59
- print "%-40s %10s\n" % ("----------------------------------------", \
60
- "-----------"),
59
+ print("%-40s %10s" % ("event", "count"))
60
+ print("%-40s %10s" % ("----------------------------------------",
61
+ "-----------"))
6162
62
- for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
63
- reverse = True):
64
- print "%-40s %10d\n" % (syscall_name(id), val),
63
+ for id, val in sorted(syscalls.items(),
64
+ key = lambda kv: (kv[1], kv[0]), reverse = True):
65
+ print("%-40s %10d" % (syscall_name(id), val))