Support both Python 2 and Python 3 in check-perf-trace.py.
``print`` is now a function rather than a statement. This should have
no functional change.
Fix indentation issue, replace spaces with tab
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/check-perf-trace.py | 32 +++++++++++++--------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/tools/perf/scripts/python/check-perf-trace.py b/tools/perf/scripts/python/check-perf-trace.py
index 334599c..1c5fab9 100644
--- a/tools/perf/scripts/python/check-perf-trace.py
+++ b/tools/perf/scripts/python/check-perf-trace.py
@@ -19,7 +19,7 @@ from perf_trace_context import *
unhandled = autodict()
def trace_begin():
- print "trace_begin"
+ print("trace_begin")
pass
def trace_end():
@@ -31,10 +31,10 @@ def irq__softirq_entry(event_name, context, common_cpu,
print_header(event_name, common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
- print_uncommon(context)
+ print_uncommon(context)
- print "vec=%s\n" % \
- (symbol_str("irq__softirq_entry", "vec", vec)),
+ print("vec=%s\n" % \
+ (symbol_str("irq__softirq_entry", "vec", vec))),
def kmem__kmalloc(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
@@ -43,13 +43,13 @@ def kmem__kmalloc(event_name, context, common_cpu,
print_header(event_name, common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
- print_uncommon(context)
+ print_uncommon(context)
- print "call_site=%u, ptr=%u, bytes_req=%u, " \
+ print("call_site=%u, ptr=%u, bytes_req=%u, " \
"bytes_alloc=%u, gfp_flags=%s\n" % \
(call_site, ptr, bytes_req, bytes_alloc,
- flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),
+ flag_str("kmem__kmalloc", "gfp_flags", gfp_flags))),
def trace_unhandled(event_name, context, event_fields_dict):
try:
@@ -58,25 +58,25 @@ def trace_unhandled(event_name, context, event_fields_dict):
unhandled[event_name] = 1
def print_header(event_name, cpu, secs, nsecs, pid, comm):
- print "%-20s %5u %05u.%09u %8u %-20s " % \
- (event_name, cpu, secs, nsecs, pid, comm),
+ print("%-20s %5u %05u.%09u %8u %-20s " % \
+ (event_name, cpu, secs, nsecs, pid, comm)),
# print trace fields not included in handler args
def print_uncommon(context):
- print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
+ print("common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
% (common_pc(context), trace_flag_str(common_flags(context)), \
- common_lock_depth(context))
+ common_lock_depth(context)))
def print_unhandled():
keys = unhandled.keys()
if not keys:
return
- print "\nunhandled events:\n\n",
+ print("\nunhandled events:\n\n"),
- print "%-40s %10s\n" % ("event", "count"),
- print "%-40s %10s\n" % ("----------------------------------------", \
- "-----------"),
+ print("%-40s %10s\n" % ("event", "count")),
+ print("%-40s %10s\n" % ("----------------------------------------", \
+ "-----------")),
for event_name in keys:
- print "%-40s %10d\n" % (event_name, unhandled[event_name])
+ print("%-40s %10d\n" % (event_name, unhandled[event_name]))
--
1.8.3.1
Support both Python 2 and Python 3 in event_analyzing_sample.py. ``print``
is now a function rather than a statement. This should have no functional
change.
Fixes indentation issue, replace spaces with tab. The "has_key()" method
is deprecated in favor of the "in" operator. So incorporate those changes
here.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
.../perf/scripts/python/event_analyzing_sample.py | 56 +++++++++++-----------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/tools/perf/scripts/python/event_analyzing_sample.py b/tools/perf/scripts/python/event_analyzing_sample.py
index 4e843b9..8cb116f 100644
--- a/tools/perf/scripts/python/event_analyzing_sample.py
+++ b/tools/perf/scripts/python/event_analyzing_sample.py
@@ -37,20 +37,20 @@ con = sqlite3.connect("/dev/shm/perf.db")
con.isolation_level = None
def trace_begin():
- print "In trace_begin:\n"
+ print("In trace_begin:\n")
#
# Will create several tables at the start, pebs_ll is for PEBS data with
# load latency info, while gen_events is for general event.
#
- con.execute("""
+ con.execute("""
create table if not exists gen_events (
name text,
symbol text,
comm text,
dso text
);""")
- con.execute("""
+ con.execute("""
create table if not exists pebs_ll (
name text,
symbol text,
@@ -76,12 +76,12 @@ def process_event(param_dict):
name = param_dict["ev_name"]
# Symbol and dso info are not always resolved
- if (param_dict.has_key("dso")):
+ if ('dso' in param_dict):
dso = param_dict["dso"]
else:
dso = "Unknown_dso"
- if (param_dict.has_key("symbol")):
+ if ('symbol' in param_dict):
symbol = param_dict["symbol"]
else:
symbol = "Unknown_symbol"
@@ -102,11 +102,11 @@ def insert_db(event):
event.ip, event.status, event.dse, event.dla, event.lat))
def trace_end():
- print "In trace_end:\n"
+ print("In trace_end:\n")
# We show the basic info for the 2 type of event classes
- show_general_events()
- show_pebs_ll()
- con.close()
+ show_general_events()
+ show_pebs_ll()
+ con.close()
#
# As the event number may be very big, so we can't use linear way
@@ -123,29 +123,29 @@ def show_general_events():
# Check the total record number in the table
count = con.execute("select count(*) from gen_events")
for t in count:
- print "There is %d records in gen_events table" % t[0]
+ print("There is %d records in gen_events table" % t[0])
if t[0] == 0:
return
- print "Statistics about the general events grouped by thread/symbol/dso: \n"
+ print("Statistics about the general events grouped by thread/symbol/dso: \n")
# Group by thread
commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)")
- print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)
+ print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42))
for row in commq:
- print "%16s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%16s %8d %s" % (row[0], row[1], num2sym(row[1])))
# Group by symbol
- print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)
+ print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58))
symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)")
for row in symbolq:
- print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%32s %8d %s" % (row[0], row[1], num2sym(row[1])))
# Group by dso
- print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74)
+ print("\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74))
dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)")
for row in dsoq:
- print "%40s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%40s %8d %s" % (row[0], row[1], num2sym(row[1])))
#
# This function just shows the basic info, and we could do more with the
@@ -156,35 +156,35 @@ def show_pebs_ll():
count = con.execute("select count(*) from pebs_ll")
for t in count:
- print "There is %d records in pebs_ll table" % t[0]
+ print("There is %d records in pebs_ll table" % t[0])
if t[0] == 0:
return
- print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n"
+ print("Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n")
# Group by thread
commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)")
- print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)
+ print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42))
for row in commq:
- print "%16s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%16s %8d %s" % (row[0], row[1], num2sym(row[1])))
# Group by symbol
- print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)
+ print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58))
symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)")
for row in symbolq:
- print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%32s %8d %s" % (row[0], row[1], num2sym(row[1])))
# Group by dse
dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)")
- print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58)
+ print("\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58))
for row in dseq:
- print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%32s %8d %s" % (row[0], row[1], num2sym(row[1])))
# Group by latency
latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat")
- print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58)
+ print("\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58))
for row in latq:
- print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
+ print("%32s %8d %s" % (row[0], row[1], num2sym(row[1])))
def trace_unhandled(event_name, context, event_fields_dict):
- print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
+ print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]))
--
1.8.3.1
Support both Python 2 and Python 3 in futex-contention.py.
``print`` is now a function rather than a statement. This should
have no functional change.
The "has_key()" method is deprecated in favor of the "in" operator.
So incorporate those changes here.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
Please enter the commit message for your changes. Lines starting
---
tools/perf/scripts/python/futex-contention.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/scripts/python/futex-contention.py b/tools/perf/scripts/python/futex-contention.py
index 0f5cf43..2f8eb81 100644
--- a/tools/perf/scripts/python/futex-contention.py
+++ b/tools/perf/scripts/python/futex-contention.py
@@ -33,18 +33,18 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
nr, ret):
- if thread_blocktime.has_key(tid):
+ if (tid in thread_blocktime):
elapsed = nsecs(s, ns) - thread_blocktime[tid]
add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
del thread_blocktime[tid]
del thread_thislock[tid]
def trace_begin():
- print "Press control+C to stop and show the summary"
+ print("Press control+C to stop and show the summary")
def trace_end():
for (tid, lock) in lock_waits:
min, max, avg, count = lock_waits[tid, lock]
- print "%s[%d] lock %x contended %d times, %d avg ns" % \
- (process_names[tid], tid, lock, count, avg)
+ print("%s[%d] lock %x contended %d times, %d avg ns" % \
+ (process_names[tid], tid, lock, count, avg))
--
1.8.3.1
Support both Python 2 and Python 3 in mem-phys-addr.py. ``print`` is now a
function rather than a statement. This should have no functional change.
Fix lambda syntax error.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/mem-phys-addr.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
index ebee2c5..52fe9bd 100644
--- a/tools/perf/scripts/python/mem-phys-addr.py
+++ b/tools/perf/scripts/python/mem-phys-addr.py
@@ -38,14 +38,14 @@ def parse_iomem():
pmem.append(long(m[1], 16))
def print_memory_type():
- print "Event: %s" % (event_name)
- print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"),
- print "%-40s %10s %10s\n" % ("----------------------------------------", \
- "-----------", "-----------"),
+ print("Event: %s" % (event_name))
+ print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage")),
+ print("%-40s %10s %10s\n" % ("----------------------------------------", \
+ "-----------", "-----------")),
total = sum(load_mem_type_cnt.values())
for mem_type, count in sorted(load_mem_type_cnt.most_common(), \
- key = lambda(k, v): (v, k), reverse = True):
- print "%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total),
+ key = lambda k_v: (k_v[1], k_v[0]), reverse = True):
+ print("%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total)),
def trace_begin():
parse_iomem()
--
1.8.3.1
Support both Python 2 and Python 3 in exported-sql-viewer.py.
``print`` is now a function rather than a statement. This should have
no functional change.
Add support of _pickle module in Python3
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/exported-sql-viewer.py | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index f278ce5..02f964a 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python2
# SPDX-License-Identifier: GPL-2.0
# exported-sql-viewer.py: view data from sql database
# Copyright (c) 2014-2018, Intel Corporation.
@@ -92,7 +91,6 @@ import sys
import weakref
import threading
import string
-import cPickle
import re
import os
from PySide.QtCore import *
@@ -102,6 +100,11 @@ from decimal import *
from ctypes import *
from multiprocessing import Process, Array, Value, Event
+if sys.version_info[0] < 3:
+ import cPickle
+else:
+ import _pickle as cPickle
+
# Data formatting helpers
def tohex(ip):
@@ -1560,7 +1563,7 @@ class SQLTableDialogDataItem():
return str(lower_id)
def ConvertRelativeTime(self, val):
- print "val ", val
+ print("val ", val)
mult = 1
suffix = val[-2:]
if suffix == "ms":
@@ -1582,29 +1585,29 @@ class SQLTableDialogDataItem():
return str(val)
def ConvertTimeRange(self, vrange):
- print "vrange ", vrange
+ print("vrange ", vrange)
if vrange[0] == "":
vrange[0] = str(self.first_time)
if vrange[1] == "":
vrange[1] = str(self.last_time)
vrange[0] = self.ConvertRelativeTime(vrange[0])
vrange[1] = self.ConvertRelativeTime(vrange[1])
- print "vrange2 ", vrange
+ print("vrange2 ", vrange)
if not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]):
return False
- print "ok1"
+ print("ok1")
beg_range = max(int(vrange[0]), self.first_time)
end_range = min(int(vrange[1]), self.last_time)
if beg_range > self.last_time or end_range < self.first_time:
return False
- print "ok2"
+ print("ok2")
vrange[0] = self.BinarySearchTime(0, self.last_id, beg_range, True)
vrange[1] = self.BinarySearchTime(1, self.last_id + 1, end_range, False)
- print "vrange3 ", vrange
+ print("vrange3 ", vrange)
return True
def AddTimeRange(self, value, ranges):
- print "value ", value
+ print("value ", value)
n = value.count("-")
if n == 1:
pass
--
1.8.3.1
Support both Python 2 and Python 3 in net_dropmonitor.py.
``print`` is now a function rather than a statement. This should
have no functional change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/net_dropmonitor.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py
index a150164..091f4b3 100755
--- a/tools/perf/scripts/python/net_dropmonitor.py
+++ b/tools/perf/scripts/python/net_dropmonitor.py
@@ -50,19 +50,19 @@ def get_sym(sloc):
return (None, 0)
def print_drop_table():
- print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
+ print("%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT"))
for i in drop_log.keys():
(sym, off) = get_sym(i)
if sym == None:
sym = i
- print "%25s %25s %25s" % (sym, off, drop_log[i])
+ print("%25s %25s %25s" % (sym, off, drop_log[i]))
def trace_begin():
- print "Starting trace (Ctrl-C to dump results)"
+ print("Starting trace (Ctrl-C to dump results)")
def trace_end():
- print "Gathering kallsyms data"
+ print("Gathering kallsyms data")
get_kallsyms_table()
print_drop_table()
--
1.8.3.1
Support both Python 2 and Python 3 in powerpc-hcalls.py.
``print`` is now a function rather than a statement. This should
have no functional change.
The "has_key()" method is deprecated in favor of the "in" operator.
So incorporate those changes here.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/powerpc-hcalls.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/scripts/python/powerpc-hcalls.py b/tools/perf/scripts/python/powerpc-hcalls.py
index 00e0e74..6cf33f0 100644
--- a/tools/perf/scripts/python/powerpc-hcalls.py
+++ b/tools/perf/scripts/python/powerpc-hcalls.py
@@ -149,7 +149,7 @@ hcall_table = {
}
def hcall_table_lookup(opcode):
- if (hcall_table.has_key(opcode)):
+ if (opcode in hcall_table):
return hcall_table[opcode]
else:
return opcode
@@ -157,8 +157,8 @@ def hcall_table_lookup(opcode):
print_ptrn = '%-28s%10s%10s%10s%10s'
def trace_end():
- print print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)')
- print '-' * 68
+ print(print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)'))
+ print('-' * 68)
for opcode in output:
h_name = hcall_table_lookup(opcode)
time = output[opcode]['time']
@@ -166,14 +166,14 @@ def trace_end():
min_t = output[opcode]['min']
max_t = output[opcode]['max']
- print print_ptrn % (h_name, cnt, min_t, max_t, time/cnt)
+ print(print_ptrn % (h_name, cnt, min_t, max_t, time/cnt))
def powerpc__hcall_exit(name, context, cpu, sec, nsec, pid, comm, callchain,
opcode, retval):
- if (d_enter.has_key(cpu) and d_enter[cpu].has_key(opcode)):
+ if ((cpu in d_enter) and (opcode in d_enter[cpu])):
diff = nsecs(sec, nsec) - d_enter[cpu][opcode]
- if (output.has_key(opcode)):
+ if (opcode in output):
output[opcode]['time'] += diff
output[opcode]['cnt'] += 1
if (output[opcode]['min'] > diff):
@@ -194,7 +194,7 @@ def powerpc__hcall_exit(name, context, cpu, sec, nsec, pid, comm, callchain,
def powerpc__hcall_entry(event_name, context, cpu, sec, nsec, pid, comm,
callchain, opcode):
- if (d_enter.has_key(cpu)):
+ if (cpu in d_enter):
d_enter[cpu][opcode] = nsecs(sec, nsec)
else:
d_enter[cpu] = {opcode: nsecs(sec, nsec)}
--
1.8.3.1
Support both Python 2 and Python 3 in failed-syscalls-by-pid.py.
``print`` is now a function rather than a statement. This should have
no functional change.
Fixes lambda syntax error.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
Please enter the commit message for your changes. Lines starting
---
tools/perf/scripts/python/failed-syscalls-by-pid.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py
index cafeff3..333c762 100644
--- a/tools/perf/scripts/python/failed-syscalls-by-pid.py
+++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py
@@ -32,7 +32,7 @@ if len(sys.argv) > 1:
syscalls = autodict()
def trace_begin():
- print "Press control+C to stop and show the summary"
+ print("Press control+C to stop and show the summary")
def trace_end():
print_error_totals()
@@ -57,22 +57,22 @@ def syscalls__sys_exit(event_name, context, common_cpu,
def print_error_totals():
if for_comm is not None:
- print "\nsyscall errors for %s:\n\n" % (for_comm),
+ print("\nsyscall errors for %s:\n\n" % (for_comm)),
else:
- print "\nsyscall errors:\n\n",
+ print("\nsyscall errors:\n\n"),
- print "%-30s %10s\n" % ("comm [pid]", "count"),
- print "%-30s %10s\n" % ("------------------------------", \
- "----------"),
+ print("%-30s %10s\n" % ("comm [pid]", "count")),
+ print("%-30s %10s\n" % ("------------------------------", \
+ "----------")),
comm_keys = syscalls.keys()
for comm in comm_keys:
pid_keys = syscalls[comm].keys()
for pid in pid_keys:
- print "\n%s [%d]\n" % (comm, pid),
+ print("\n%s [%d]\n" % (comm, pid)),
id_keys = syscalls[comm][pid].keys()
for id in id_keys:
- print " syscall: %-16s\n" % syscall_name(id),
+ print(" syscall: %-16s\n" % syscall_name(id)),
ret_keys = syscalls[comm][pid][id].keys()
- for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True):
- print " err = %-20s %10d\n" % (strerror(ret), val),
+ for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda k_v: (k_v[1], k_v[0]), reverse = True):
+ print(" err = %-20s %10d\n" % (strerror(ret), val)),
--
1.8.3.1
Support both Python 2 and Python 3 in netdev-times.py. ``print``
is now a function rather than a statement. This should have no
functional change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/netdev-times.py | 76 +++++++++++++++----------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/tools/perf/scripts/python/netdev-times.py b/tools/perf/scripts/python/netdev-times.py
index 9b2050f..65cf276 100644
--- a/tools/perf/scripts/python/netdev-times.py
+++ b/tools/perf/scripts/python/netdev-times.py
@@ -61,12 +61,12 @@ def diff_msec(src, dst):
def print_transmit(hunk):
if dev != 0 and hunk['dev'].find(dev) < 0:
return
- print "%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \
+ print("%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \
(hunk['dev'], hunk['len'],
nsecs_secs(hunk['queue_t']),
nsecs_nsecs(hunk['queue_t'])/1000,
diff_msec(hunk['queue_t'], hunk['xmit_t']),
- diff_msec(hunk['xmit_t'], hunk['free_t']))
+ diff_msec(hunk['xmit_t'], hunk['free_t'])))
# Format for displaying rx packet processing
PF_IRQ_ENTRY= " irq_entry(+%.3fmsec irq=%d:%s)"
@@ -98,55 +98,55 @@ def print_receive(hunk):
if show_hunk == 0:
return
- print "%d.%06dsec cpu=%d" % \
- (nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu)
+ print("%d.%06dsec cpu=%d" % \
+ (nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu))
for i in range(len(irq_list)):
- print PF_IRQ_ENTRY % \
+ print(PF_IRQ_ENTRY % \
(diff_msec(base_t, irq_list[i]['irq_ent_t']),
- irq_list[i]['irq'], irq_list[i]['name'])
- print PF_JOINT
+ irq_list[i]['irq'], irq_list[i]['name']))
+ print(PF_JOINT)
irq_event_list = irq_list[i]['event_list']
for j in range(len(irq_event_list)):
irq_event = irq_event_list[j]
if irq_event['event'] == 'netif_rx':
- print PF_NET_RX % \
+ print(PF_NET_RX % \
(diff_msec(base_t, irq_event['time']),
- irq_event['skbaddr'])
- print PF_JOINT
- print PF_SOFT_ENTRY % \
- diff_msec(base_t, hunk['sirq_ent_t'])
- print PF_JOINT
+ irq_event['skbaddr']))
+ print(PF_JOINT)
+ print(PF_SOFT_ENTRY % \
+ diff_msec(base_t, hunk['sirq_ent_t']))
+ print(PF_JOINT)
event_list = hunk['event_list']
for i in range(len(event_list)):
event = event_list[i]
if event['event_name'] == 'napi_poll':
- print PF_NAPI_POLL % \
- (diff_msec(base_t, event['event_t']), event['dev'])
+ print(PF_NAPI_POLL % \
+ (diff_msec(base_t, event['event_t']), event['dev']))
if i == len(event_list) - 1:
- print ""
+ print("")
else:
- print PF_JOINT
+ print(PF_JOINT)
else:
- print PF_NET_RECV % \
+ print(PF_NET_RECV % \
(diff_msec(base_t, event['event_t']), event['skbaddr'],
- event['len'])
+ event['len']))
if 'comm' in event.keys():
- print PF_WJOINT
- print PF_CPY_DGRAM % \
+ print(PF_WJOINT)
+ print(PF_CPY_DGRAM % \
(diff_msec(base_t, event['comm_t']),
- event['pid'], event['comm'])
+ event['pid'], event['comm']))
elif 'handle' in event.keys():
- print PF_WJOINT
+ print(PF_WJOINT)
if event['handle'] == "kfree_skb":
- print PF_KFREE_SKB % \
+ print(PF_KFREE_SKB % \
(diff_msec(base_t,
event['comm_t']),
- event['location'])
+ event['location']))
elif event['handle'] == "consume_skb":
- print PF_CONS_SKB % \
+ print(PF_CONS_SKB % \
diff_msec(base_t,
- event['comm_t'])
- print PF_JOINT
+ event['comm_t']))
+ print(PF_JOINT)
def trace_begin():
global show_tx
@@ -210,19 +210,19 @@ def trace_end():
print_receive(receive_hunk_list[i])
# display transmit hunks
if show_tx:
- print " dev len Qdisc " \
- " netdevice free"
+ print(" dev len Qdisc " \
+ " netdevice free")
for i in range(len(tx_free_list)):
print_transmit(tx_free_list[i])
if debug:
- print "debug buffer status"
- print "----------------------------"
- print "xmit Qdisc:remain:%d overflow:%d" % \
- (len(tx_queue_list), of_count_tx_queue_list)
- print "xmit netdevice:remain:%d overflow:%d" % \
- (len(tx_xmit_list), of_count_tx_xmit_list)
- print "receive:remain:%d overflow:%d" % \
- (len(rx_skb_list), of_count_rx_skb_list)
+ print("debug buffer status")
+ print("----------------------------")
+ print("xmit Qdisc:remain:%d overflow:%d" % \
+ (len(tx_queue_list), of_count_tx_queue_list))
+ print("xmit netdevice:remain:%d overflow:%d" % \
+ (len(tx_xmit_list), of_count_tx_xmit_list))
+ print("receive:remain:%d overflow:%d" % \
+ (len(rx_skb_list), of_count_rx_skb_list))
# called from perf, when it finds a correspoinding event
def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
--
1.8.3.1
Support both Python 2 and Python 3 in syscall-counts-by-pid.py. ``print``
is now a function rather than a statement. This should have no functional
change.
Fix lambda syntax error.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/syscall-counts-by-pid.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/perf/scripts/python/syscall-counts-by-pid.py b/tools/perf/scripts/python/syscall-counts-by-pid.py
index daf314c..f3f17fd 100644
--- a/tools/perf/scripts/python/syscall-counts-by-pid.py
+++ b/tools/perf/scripts/python/syscall-counts-by-pid.py
@@ -31,7 +31,7 @@ if len(sys.argv) > 1:
syscalls = autodict()
def trace_begin():
- print "Press control+C to stop and show the summary"
+ print("Press control+C to stop and show the summary")
def trace_end():
print_syscall_totals()
@@ -55,20 +55,20 @@ def syscalls__sys_enter(event_name, context, common_cpu,
def print_syscall_totals():
if for_comm is not None:
- print "\nsyscall events for %s:\n\n" % (for_comm),
+ print("\nsyscall events for %s:\n\n" % (for_comm)),
else:
- print "\nsyscall events by comm/pid:\n\n",
+ print("\nsyscall events by comm/pid:\n\n"),
- print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"),
- print "%-40s %10s\n" % ("----------------------------------------", \
- "----------"),
+ print("%-40s %10s\n" % ("comm [pid]/syscalls", "count")),
+ print("%-40s %10s\n" % ("----------------------------------------", \
+ "----------")),
comm_keys = syscalls.keys()
for comm in comm_keys:
pid_keys = syscalls[comm].keys()
for pid in pid_keys:
- print "\n%s [%d]\n" % (comm, pid),
+ print("\n%s [%d]\n" % (comm, pid)),
id_keys = syscalls[comm][pid].keys()
for id, val in sorted(syscalls[comm][pid].iteritems(), \
- key = lambda(k, v): (v, k), reverse = True):
- print " %-38s %10d\n" % (syscall_name(id), val),
+ key = lambda k_v: (k_v[1], k_v[0]), reverse = True):
+ print(" %-38s %10d\n" % (syscall_name(id), val)),
--
1.8.3.1
Support both Python 2 and Python 3 in intel-pt-events.py.``print``
is now a function rather than a statement. This should have no
functional change.
Fixes indentation issue, replace spaces with tab.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/intel-pt-events.py | 56 ++++++++++++++--------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
index b19172d..a02a810 100644
--- a/tools/perf/scripts/python/intel-pt-events.py
+++ b/tools/perf/scripts/python/intel-pt-events.py
@@ -22,34 +22,34 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
#from Core import *
def trace_begin():
- print "Intel PT Power Events and PTWRITE"
+ print("Intel PT Power Events and PTWRITE")
def trace_end():
- print "End"
+ print("End")
def trace_unhandled(event_name, context, event_fields_dict):
- print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
+ print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]))
def print_ptwrite(raw_buf):
data = struct.unpack_from("<IQ", raw_buf)
flags = data[0]
payload = data[1]
exact_ip = flags & 1
- print "IP: %u payload: %#x" % (exact_ip, payload),
+ print("IP: %u payload: %#x" % (exact_ip, payload)),
def print_cbr(raw_buf):
data = struct.unpack_from("<BBBBII", raw_buf)
cbr = data[0]
f = (data[4] + 500) / 1000
p = ((cbr * 1000 / data[2]) + 5) / 10
- print "%3u freq: %4u MHz (%3u%%)" % (cbr, f, p),
+ print("%3u freq: %4u MHz (%3u%%)" % (cbr, f, p)),
def print_mwait(raw_buf):
data = struct.unpack_from("<IQ", raw_buf)
payload = data[1]
hints = payload & 0xff
extensions = (payload >> 32) & 0x3
- print "hints: %#x extensions: %#x" % (hints, extensions),
+ print("hints: %#x extensions: %#x" % (hints, extensions)),
def print_pwre(raw_buf):
data = struct.unpack_from("<IQ", raw_buf)
@@ -57,13 +57,13 @@ def print_pwre(raw_buf):
hw = (payload >> 7) & 1
cstate = (payload >> 12) & 0xf
subcstate = (payload >> 8) & 0xf
- print "hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate),
+ print("hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate)),
def print_exstop(raw_buf):
data = struct.unpack_from("<I", raw_buf)
flags = data[0]
exact_ip = flags & 1
- print "IP: %u" % (exact_ip),
+ print("IP: %u" % (exact_ip)),
def print_pwrx(raw_buf):
data = struct.unpack_from("<IQ", raw_buf)
@@ -71,37 +71,37 @@ def print_pwrx(raw_buf):
deepest_cstate = payload & 0xf
last_cstate = (payload >> 4) & 0xf
wake_reason = (payload >> 8) & 0xf
- print "deepest cstate: %u last cstate: %u wake reason: %#x" % (deepest_cstate, last_cstate, wake_reason),
+ print("deepest cstate: %u last cstate: %u wake reason: %#x" % (deepest_cstate, last_cstate, wake_reason)),
def print_common_start(comm, sample, name):
ts = sample["time"]
cpu = sample["cpu"]
pid = sample["pid"]
tid = sample["tid"]
- print "%16s %5u/%-5u [%03u] %9u.%09u %7s:" % (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000, name),
+ print("%16s %5u/%-5u [%03u] %9u.%09u %7s:" % (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000, name)),
def print_common_ip(sample, symbol, dso):
ip = sample["ip"]
- print "%16x %s (%s)" % (ip, symbol, dso)
+ print("%16x %s (%s)" % (ip, symbol, dso))
def process_event(param_dict):
- event_attr = param_dict["attr"]
- sample = param_dict["sample"]
- raw_buf = param_dict["raw_buf"]
- comm = param_dict["comm"]
- name = param_dict["ev_name"]
-
- # Symbol and dso info are not always resolved
- if (param_dict.has_key("dso")):
- dso = param_dict["dso"]
- else:
- dso = "[unknown]"
-
- if (param_dict.has_key("symbol")):
- symbol = param_dict["symbol"]
- else:
- symbol = "[unknown]"
-
+ event_attr = param_dict["attr"]
+ sample = param_dict["sample"]
+ raw_buf = param_dict["raw_buf"]
+ comm = param_dict["comm"]
+ name = param_dict["ev_name"]
+
+ # Symbol and dso info are not always resolved
+ if ('dso' in param_dict):
+ dso = param_dict["dso"]
+ else:
+ dso = "[unknown]"
+
+ if ('symbol' in param_dict):
+ symbol = param_dict["symbol"]
+ else:
+ symbol = "[unknown]"
+
if name == "ptwrite":
print_common_start(comm, sample, name)
print_ptwrite(raw_buf)
--
1.8.3.1
Support both Python 2 and Python 3 in syscall-counts.py. ``print``
is now a function rather than a statement. This should have no
functional change.
Fix lambda syntax error
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/syscall-counts.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/scripts/python/syscall-counts.py b/tools/perf/scripts/python/syscall-counts.py
index e66a773..141b7fc 100644
--- a/tools/perf/scripts/python/syscall-counts.py
+++ b/tools/perf/scripts/python/syscall-counts.py
@@ -28,7 +28,7 @@ if len(sys.argv) > 1:
syscalls = autodict()
def trace_begin():
- print "Press control+C to stop and show the summary"
+ print("Press control+C to stop and show the summary")
def trace_end():
print_syscall_totals()
@@ -51,14 +51,14 @@ def syscalls__sys_enter(event_name, context, common_cpu,
def print_syscall_totals():
if for_comm is not None:
- print "\nsyscall events for %s:\n\n" % (for_comm),
+ print("\nsyscall events for %s:\n\n" % (for_comm)),
else:
- print "\nsyscall events:\n\n",
+ print("\nsyscall events:\n\n"),
- print "%-40s %10s\n" % ("event", "count"),
- print "%-40s %10s\n" % ("----------------------------------------", \
- "-----------"),
+ print("%-40s %10s\n" % ("event", "count")),
+ print("%-40s %10s\n" % ("----------------------------------------", \
+ "-----------")),
- for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
+ for id, val in sorted(syscalls.iteritems(), key = lambda k_v: (k_v[1], k_v[0]), \
reverse = True):
- print "%-40s %10d\n" % (syscall_name(id), val),
+ print("%-40s %10d\n" % (syscall_name(id), val)),
--
1.8.3.1
Support both Python 2 and Python 3 in export-to-postgresql.py. ``print``
is now a function rather than a statement. This should have no functional
change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/export-to-postgresql.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py
index 0564dd7..6774909 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -273,7 +273,7 @@ def do_query(q, s):
return
raise Exception("Query failed: " + q.lastError().text())
-print datetime.datetime.today(), "Creating database..."
+print(datetime.datetime.today(), "Creating database...")
db = QSqlDatabase.addDatabase('QPSQL')
query = QSqlQuery(db)
@@ -564,7 +564,7 @@ if perf_db_export_calls:
call_file = open_output_file("call_table.bin")
def trace_begin():
- print datetime.datetime.today(), "Writing to intermediate files..."
+ print(datetime.datetime.today(), "Writing to intermediate files...")
# id == 0 means unknown. It is easier to create records for them than replace the zeroes with NULLs
evsel_table(0, "unknown")
machine_table(0, 0, "unknown")
@@ -579,7 +579,7 @@ def trace_begin():
unhandled_count = 0
def trace_end():
- print datetime.datetime.today(), "Copying to database..."
+ print(datetime.datetime.today(), "Copying to database...")
copy_output_file(evsel_file, "selected_events")
copy_output_file(machine_file, "machines")
copy_output_file(thread_file, "threads")
@@ -594,7 +594,7 @@ def trace_end():
if perf_db_export_calls:
copy_output_file(call_file, "calls")
- print datetime.datetime.today(), "Removing intermediate files..."
+ print(datetime.datetime.today(), "Removing intermediate files...")
remove_output_file(evsel_file)
remove_output_file(machine_file)
remove_output_file(thread_file)
@@ -609,7 +609,7 @@ def trace_end():
if perf_db_export_calls:
remove_output_file(call_file)
os.rmdir(output_dir_name)
- print datetime.datetime.today(), "Adding primary keys"
+ print(datetime.datetime.today(), "Adding primary keys")
do_query(query, 'ALTER TABLE selected_events ADD PRIMARY KEY (id)')
do_query(query, 'ALTER TABLE machines ADD PRIMARY KEY (id)')
do_query(query, 'ALTER TABLE threads ADD PRIMARY KEY (id)')
@@ -624,7 +624,7 @@ def trace_end():
if perf_db_export_calls:
do_query(query, 'ALTER TABLE calls ADD PRIMARY KEY (id)')
- print datetime.datetime.today(), "Adding foreign keys"
+ print(datetime.datetime.today(), "Adding foreign keys")
do_query(query, 'ALTER TABLE threads '
'ADD CONSTRAINT machinefk FOREIGN KEY (machine_id) REFERENCES machines (id),'
'ADD CONSTRAINT processfk FOREIGN KEY (process_id) REFERENCES threads (id)')
@@ -659,8 +659,8 @@ def trace_end():
do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)')
if (unhandled_count):
- print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events"
- print datetime.datetime.today(), "Done"
+ print(datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events")
+ print(datetime.datetime.today(), "Done")
def trace_unhandled(event_name, context, event_fields_dict):
global unhandled_count
--
1.8.3.1
Support both Python 2 and Python 3 in sctop.py.``print``
is now a function rather than a statement. This should have no
functional change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/sctop.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/scripts/python/sctop.py b/tools/perf/scripts/python/sctop.py
index 61621b9..ea8edcf 100644
--- a/tools/perf/scripts/python/sctop.py
+++ b/tools/perf/scripts/python/sctop.py
@@ -62,18 +62,18 @@ def print_syscall_totals(interval):
while 1:
clear_term()
if for_comm is not None:
- print "\nsyscall events for %s:\n\n" % (for_comm),
+ print("\nsyscall events for %s:\n\n" % (for_comm)),
else:
- print "\nsyscall events:\n\n",
+ print("\nsyscall events:\n\n"),
- print "%-40s %10s\n" % ("event", "count"),
- print "%-40s %10s\n" % ("----------------------------------------", \
- "----------"),
+ print("%-40s %10s\n" % ("event", "count")),
+ print("%-40s %10s\n" % ("----------------------------------------", \
+ "----------")),
- for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
+ for id, val in sorted(syscalls.iteritems(), key = lambda k_v: (k_v[1], k_v[0]), \
reverse = True):
try:
- print "%-40s %10d\n" % (syscall_name(id), val),
+ print("%-40s %10d\n" % (syscall_name(id), val)),
except TypeError:
pass
syscalls.clear()
--
1.8.3.1
Support both Python 2 and Python 3 in stat-cpi.py. ``print``
is now a function rather than a statement. This should have no
functional change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/stat-cpi.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/stat-cpi.py b/tools/perf/scripts/python/stat-cpi.py
index 8410672..1d8e8b7 100644
--- a/tools/perf/scripts/python/stat-cpi.py
+++ b/tools/perf/scripts/python/stat-cpi.py
@@ -59,7 +59,7 @@ def stat__interval(time):
if ins != 0:
cpi = cyc/float(ins)
- print "%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins)
+ print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins))
def trace_end():
pass
--
1.8.3.1
On Wed, 16 Jan 2019 21:53:36 +0530
Seeteena Thoufeek <[email protected]> wrote:
> Support both Python 2 and Python 3 in mem-phys-addr.py. ``print`` is now a
> function rather than a statement. This should have no functional change.
>
> Fix lambda syntax error.
So, I just picked one of these at random....
> Signed-off-by: Seeteena Thoufeek <[email protected]>
> Reviewed-by: Ravi Bangoria <[email protected]>
> ---
> tools/perf/scripts/python/mem-phys-addr.py | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
> index ebee2c5..52fe9bd 100644
> --- a/tools/perf/scripts/python/mem-phys-addr.py
> +++ b/tools/perf/scripts/python/mem-phys-addr.py
> @@ -38,14 +38,14 @@ def parse_iomem():
> pmem.append(long(m[1], 16))
>
> def print_memory_type():
> - print "Event: %s" % (event_name)
> - print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"),
> - print "%-40s %10s %10s\n" % ("----------------------------------------", \
> - "-----------", "-----------"),
> + print("Event: %s" % (event_name))
> + print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage")),
> + print("%-40s %10s %10s\n" % ("----------------------------------------", \
> + "-----------", "-----------")),
You have not added "from __future__ import print_function", so you're
relying on a Python 2 parsing oddity to make this work. If anybody ever
adds a second parameter, things will break. I think that if you really
want to support both versions (which seems like the right goal) you should
add the import and do it properly.
Thanks,
jon
Support both Python 2 and Python 3 in stackcollapse.py. ``print`` is now a
function rather than a statement. This should have no functional change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/stackcollapse.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py
index 1697b5e..3edeb7e 100755
--- a/tools/perf/scripts/python/stackcollapse.py
+++ b/tools/perf/scripts/python/stackcollapse.py
@@ -123,4 +123,4 @@ def trace_end():
list = lines.keys()
list.sort()
for stack in list:
- print "%s %d" % (stack, lines[stack])
+ print("%s %d" % (stack, lines[stack]))
--
1.8.3.1
Support both Python 2 and Python 3 in export-to-sqlite.py. ``print`` is
now a function rather than a statement. This should have no functional
change.
Signed-off-by: Seeteena Thoufeek <[email protected]>
Reviewed-by: Ravi Bangoria <[email protected]>
---
tools/perf/scripts/python/export-to-sqlite.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
index 245caf2..530b9e3 100644
--- a/tools/perf/scripts/python/export-to-sqlite.py
+++ b/tools/perf/scripts/python/export-to-sqlite.py
@@ -100,7 +100,7 @@ def do_query_(q):
return
raise Exception("Query failed: " + q.lastError().text())
-print datetime.datetime.today(), "Creating database..."
+print(datetime.datetime.today(), "Creating database...")
db_exists = False
try:
@@ -376,7 +376,7 @@ if perf_db_export_calls:
call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
def trace_begin():
- print datetime.datetime.today(), "Writing records..."
+ print(datetime.datetime.today(), "Writing records...")
do_query(query, 'BEGIN TRANSACTION')
# id == 0 means unknown. It is easier to create records for them than replace the zeroes with NULLs
evsel_table(0, "unknown")
@@ -394,13 +394,13 @@ unhandled_count = 0
def trace_end():
do_query(query, 'END TRANSACTION')
- print datetime.datetime.today(), "Adding indexes"
+ print(datetime.datetime.today(), "Adding indexes")
if perf_db_export_calls:
do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)')
if (unhandled_count):
- print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events"
- print datetime.datetime.today(), "Done"
+ print(datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events")
+ print(datetime.datetime.today(), "Done")
def trace_unhandled(event_name, context, event_fields_dict):
global unhandled_count
--
1.8.3.1
I have added
On 01/16/2019 10:02 PM, Jonathan Corbet wrote:
> On Wed, 16 Jan 2019 21:53:36 +0530
> Seeteena Thoufeek <[email protected]> wrote:
>
>> Support both Python 2 and Python 3 in mem-phys-addr.py. ``print`` is now a
>> function rather than a statement. This should have no functional change.
>>
>> Fix lambda syntax error.
> So, I just picked one of these at random....
>
>> Signed-off-by: Seeteena Thoufeek <[email protected]>
>> Reviewed-by: Ravi Bangoria <[email protected]>
>> ---
>> tools/perf/scripts/python/mem-phys-addr.py | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
>> index ebee2c5..52fe9bd 100644
>> --- a/tools/perf/scripts/python/mem-phys-addr.py
>> +++ b/tools/perf/scripts/python/mem-phys-addr.py
>> @@ -38,14 +38,14 @@ def parse_iomem():
>> pmem.append(long(m[1], 16))
>>
>> def print_memory_type():
>> - print "Event: %s" % (event_name)
>> - print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"),
>> - print "%-40s %10s %10s\n" % ("----------------------------------------", \
>> - "-----------", "-----------"),
>> + print("Event: %s" % (event_name))
>> + print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage")),
>> + print("%-40s %10s %10s\n" % ("----------------------------------------", \
>> + "-----------", "-----------")),
> You have not added "from __future__ import print_function", so you're
> relying on a Python 2 parsing oddity to make this work. If anybody ever
> adds a second parameter, things will break. I think that if you really
> want to support both versions (which seems like the right goal) you should
> add the import and do it properly.
>
> Thanks,
>
> jon
>
Thanks Jonathan. I have added "from __future__ import print_function"
for all the scripts.
On 1/17/19 1:48 AM, seeteena wrote:
> I have added
>> You have not added "from __future__ import print_function", so you're
>> relying on a Python 2 parsing oddity to make this work.
I didn't see Jon's comment earlier. Sorry to have given conflicting advice. I'd not considered it a parsing oddity but I think he's correct.
There is a flip side however and that is that this oddity probably works in versions older than v2.6 which is as far back as future support exists.
I can't imagine anyone is using < 2.6 but I have no idea what PYTHON=python2 actually implies. The other option is to switch to sys.write.stdout
which has always had more consistent semantics.
Tony