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
Showing the changes to tools/perf/scripts/python/stackcollapse.py (1 of 1 file). Show all
Unified · Split
| @@ -19,6 +19,8 @@ · 18 unmodified lines | ||
| 19 | 19 | # Written by Paolo Bonzini <pbonzini@redhat.com> |
| 20 | 20 | # Based on Brendan Gregg's stackcollapse-perf.pl script. |
| 21 | 21 | |
| 22 | +from __future__ import print_function | |
| 23 | + | |
| 22 | 24 | import os |
| 23 | 25 | import sys |
| 24 | 26 | from collections import defaultdict |
| @@ -120,7 +122,6 @@ def process_event(param_dict): · 95 unmodified lines | ||
| 120 | 122 | lines[stack_string] = lines[stack_string] + 1 |
| 121 | 123 | |
| 122 | 124 | def trace_end(): |
| 123 | − list = lines.keys() | |
| 124 | − list.sort() | |
| 125 | + list = sorted(lines) | |
| 125 | 126 | for stack in list: |
| 126 | − print "%s %d" % (stack, lines[stack]) | |
| 127 | + print("%s %d" % (stack, lines[stack])) | |