History

perf script python: Add Python3 support to stackcollapse.py

Support both Python2 and Python3 in the stackcollapse.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 6d22d991 parent ee75a891 file · +4 −3Browse files

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

Unified · Split

tools/perf/scripts/python/stackcollapse.py+4−3
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919 # Written by Paolo Bonzini <pbonzini@redhat.com>
2020 # Based on Brendan Gregg's stackcollapse-perf.pl script.
2121
22+from __future__ import print_function
23+
2224 import os
2325 import sys
2426 from collections import defaultdict
@@ -120,7 +122,6 @@ def process_event(param_dict): · 95 unmodified lines
120122 lines[stack_string] = lines[stack_string] + 1
121123
122124 def trace_end():
123− list = lines.keys()
124− list.sort()
125+ list = sorted(lines)
125126 for stack in list:
126− print "%s %d" % (stack, lines[stack])
127+ print("%s %d" % (stack, lines[stack]))