diff options
author | Tony Jones <tonyj@suse.de> | 2019-02-22 18:06:17 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-25 15:17:10 -0500 |
commit | 1d1b0dbb859d175eb512a9f0e1ca7e44bd0192cd (patch) | |
tree | f70ab99965f332199ed4926d8d489a5695402847 /tools/perf/scripts/python/syscall-counts.py | |
parent | e985bf761db7646cebcd236249da08bd264069de (diff) |
perf script python: Add Python3 support to syscall-counts.py
Support both Python2 and Python3 in the syscall-counts.py script
There may be differences in the ordering of output lines due to
differences in dictionary ordering etc. However the format within lines
should be unchanged.
The use of 'from __future__' implies the minimum supported Python2 version
is now v2.6
Signed-off-by: Tony Jones <tonyj@suse.de>
Link: http://lkml.kernel.org/r/20190222230619.17887-14-tonyj@suse.de
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/syscall-counts.py')
-rw-r--r-- | tools/perf/scripts/python/syscall-counts.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/perf/scripts/python/syscall-counts.py b/tools/perf/scripts/python/syscall-counts.py index e66a7730aeb5..0ebd89cfd42c 100644 --- a/tools/perf/scripts/python/syscall-counts.py +++ b/tools/perf/scripts/python/syscall-counts.py | |||
@@ -5,6 +5,8 @@ | |||
5 | # Displays system-wide system call totals, broken down by syscall. | 5 | # Displays system-wide system call totals, broken down by syscall. |
6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. | 6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. |
7 | 7 | ||
8 | from __future__ import print_function | ||
9 | |||
8 | import os | 10 | import os |
9 | import sys | 11 | import sys |
10 | 12 | ||
@@ -28,7 +30,7 @@ if len(sys.argv) > 1: | |||
28 | syscalls = autodict() | 30 | syscalls = autodict() |
29 | 31 | ||
30 | def trace_begin(): | 32 | 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") |
32 | 34 | ||
33 | def trace_end(): | 35 | def trace_end(): |
34 | print_syscall_totals() | 36 | print_syscall_totals() |
@@ -51,14 +53,14 @@ def syscalls__sys_enter(event_name, context, common_cpu, | |||
51 | 53 | ||
52 | def print_syscall_totals(): | 54 | def print_syscall_totals(): |
53 | if for_comm is not None: | 55 | if for_comm is not None: |
54 | print "\nsyscall events for %s:\n\n" % (for_comm), | 56 | print("\nsyscall events for %s:\n" % (for_comm)) |
55 | else: | 57 | else: |
56 | print "\nsyscall events:\n\n", | 58 | print("\nsyscall events:\n") |
57 | 59 | ||
58 | print "%-40s %10s\n" % ("event", "count"), | 60 | print("%-40s %10s" % ("event", "count")) |
59 | print "%-40s %10s\n" % ("----------------------------------------", \ | 61 | print("%-40s %10s" % ("----------------------------------------", |
60 | "-----------"), | 62 | "-----------")) |
61 | 63 | ||
62 | for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ | 64 | for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \ |
63 | reverse = True): | 65 | reverse = True): |
64 | print "%-40s %10d\n" % (syscall_name(id), val), | 66 | print("%-40s %10d" % (syscall_name(id), val)) |