History

perf script python: Add Python3 support to futex-contention.py

Support both Python2 and Python3 in the futex-contention.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

Tony Jones committed 7 years ago

Commit de2ec161 parent b504d7f1 file · +6 −4Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/futex-contention.py+6−4
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #
1111 # Measures futex contention
1212
13+from __future__ import print_function
14+
1315 import os, sys
1416 sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
1517 from Util import *
@@ -33,18 +35,18 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, · 17 unmodified lines
3335
3436 def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
3537 nr, ret):
36− if thread_blocktime.has_key(tid):
38+ if tid in thread_blocktime:
3739 elapsed = nsecs(s, ns) - thread_blocktime[tid]
3840 add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
3941 del thread_blocktime[tid]
4042 del thread_thislock[tid]
4143
4244 def trace_begin():
43− print "Press control+C to stop and show the summary"
45+ print("Press control+C to stop and show the summary")
4446
4547 def trace_end():
4648 for (tid, lock) in lock_waits:
4749 min, max, avg, count = lock_waits[tid, lock]
48− print "%s[%d] lock %x contended %d times, %d avg ns" % \
49− (process_names[tid], tid, lock, count, avg)
50+ print("%s[%d] lock %x contended %d times, %d avg ns" %
51+ (process_names[tid], tid, lock, count, avg))
5052

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t