Skip to content

Commit 1d1b0db

Browse files
tonyj-suseacmel
authored andcommitted
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>
1 parent e985bf7 commit 1d1b0db

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tools/perf/scripts/python/syscall-counts.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +30,7 @@
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()
@@ -51,14 +53,14 @@ def syscalls__sys_enter(event_name, context, common_cpu,
5153

5254
def print_syscall_totals():
5355
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))
5557
else:
56-
print "\nsyscall events:\n\n",
58+
print("\nsyscall events:\n")
5759

58-
print "%-40s %10s\n" % ("event", "count"),
59-
print "%-40s %10s\n" % ("----------------------------------------", \
60-
"-----------"),
60+
print("%-40s %10s" % ("event", "count"))
61+
print("%-40s %10s" % ("----------------------------------------",
62+
"-----------"))
6163

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]), \
6365
reverse = True):
64-
print "%-40s %10d\n" % (syscall_name(id), val),
66+
print("%-40s %10d" % (syscall_name(id), val))

0 commit comments

Comments
 (0)