Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script python: Add Python3 support to stat-cpi.py

Support both Python2 and Python3 in the stat-cpi.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: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190222230619.17887-13-tonyj@suse.de
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tony Jones and committed by
Arnaldo Carvalho de Melo
e985bf76 6d22d999

+6 -4
+6 -4
tools/perf/scripts/python/stat-cpi.py
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 + from __future__ import print_function 4 + 3 5 data = {} 4 6 times = [] 5 7 threads = [] ··· 21 19 threads.append(thread) 22 20 23 21 def store(time, event, cpu, thread, val, ena, run): 24 - #print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \ 25 - # (event, cpu, thread, time, val, ena, run) 22 + #print("event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % 23 + # (event, cpu, thread, time, val, ena, run)) 26 24 27 25 store_key(time, cpu, thread) 28 26 key = get_key(time, event, cpu, thread) ··· 60 58 if ins != 0: 61 59 cpi = cyc/float(ins) 62 60 63 - print "%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins) 61 + print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins)) 64 62 65 63 def trace_end(): 66 64 pass ··· 76 74 # if ins != 0: 77 75 # cpi = cyc/float(ins) 78 76 # 79 - # print "time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi) 77 + # print("time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi))