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
19# Written by Paolo Bonzini <pbonzini@redhat.com>19# Written by Paolo Bonzini <pbonzini@redhat.com>
20# Based on Brendan Gregg's stackcollapse-perf.pl script.20# Based on Brendan Gregg's stackcollapse-perf.pl script.
21 21
22from __future__ import print_function
23
22import os24import os
23import sys25import sys
24from collections import defaultdict26from collections import defaultdict
@@ -120,7 +122,6 @@ def process_event(param_dict): · 95 unmodified lines
120 lines[stack_string] = lines[stack_string] + 1122 lines[stack_string] = lines[stack_string] + 1
121 123
122def trace_end():124def trace_end():
123 list = lines.keys()125 list = sorted(lines)
124 list.sort()
125 for stack in list:126 for stack in list:
126 print "%s %d" % (stack, lines[stack])127 print("%s %d" % (stack, lines[stack]))