.. | .. |
---|
4 | 4 | # Copyright (c) 2018, Intel Corporation. |
---|
5 | 5 | |
---|
6 | 6 | from __future__ import division |
---|
| 7 | +from __future__ import print_function |
---|
| 8 | + |
---|
7 | 9 | import os |
---|
8 | 10 | import sys |
---|
9 | 11 | import struct |
---|
.. | .. |
---|
31 | 33 | for i, j in enumerate(f): |
---|
32 | 34 | m = re.split('-|:',j,2) |
---|
33 | 35 | if m[2].strip() == 'System RAM': |
---|
34 | | - system_ram.append(long(m[0], 16)) |
---|
35 | | - system_ram.append(long(m[1], 16)) |
---|
| 36 | + system_ram.append(int(m[0], 16)) |
---|
| 37 | + system_ram.append(int(m[1], 16)) |
---|
36 | 38 | if m[2].strip() == 'Persistent Memory': |
---|
37 | | - pmem.append(long(m[0], 16)) |
---|
38 | | - pmem.append(long(m[1], 16)) |
---|
| 39 | + pmem.append(int(m[0], 16)) |
---|
| 40 | + pmem.append(int(m[1], 16)) |
---|
39 | 41 | |
---|
40 | 42 | def print_memory_type(): |
---|
41 | | - print "Event: %s" % (event_name) |
---|
42 | | - print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), |
---|
43 | | - print "%-40s %10s %10s\n" % ("----------------------------------------", \ |
---|
| 43 | + print("Event: %s" % (event_name)) |
---|
| 44 | + print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='') |
---|
| 45 | + print("%-40s %10s %10s\n" % ("----------------------------------------", |
---|
44 | 46 | "-----------", "-----------"), |
---|
| 47 | + end=''); |
---|
45 | 48 | total = sum(load_mem_type_cnt.values()) |
---|
46 | 49 | for mem_type, count in sorted(load_mem_type_cnt.most_common(), \ |
---|
47 | | - key = lambda(k, v): (v, k), reverse = True): |
---|
48 | | - print "%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total), |
---|
| 50 | + key = lambda kv: (kv[1], kv[0]), reverse = True): |
---|
| 51 | + print("%-40s %10d %10.1f%%\n" % |
---|
| 52 | + (mem_type, count, 100 * count / total), |
---|
| 53 | + end='') |
---|
49 | 54 | |
---|
50 | 55 | def trace_begin(): |
---|
51 | 56 | parse_iomem() |
---|
.. | .. |
---|
80 | 85 | f.seek(0, 0) |
---|
81 | 86 | for j in f: |
---|
82 | 87 | m = re.split('-|:',j,2) |
---|
83 | | - if long(m[0], 16) <= phys_addr <= long(m[1], 16): |
---|
| 88 | + if int(m[0], 16) <= phys_addr <= int(m[1], 16): |
---|
84 | 89 | return m[2] |
---|
85 | 90 | return "N/A" |
---|
86 | 91 | |
---|