.. | .. |
---|
4 | 4 | # |
---|
5 | 5 | # Hypervisor call statisics |
---|
6 | 6 | |
---|
| 7 | +from __future__ import print_function |
---|
| 8 | + |
---|
7 | 9 | import os |
---|
8 | 10 | import sys |
---|
9 | 11 | |
---|
.. | .. |
---|
149 | 151 | } |
---|
150 | 152 | |
---|
151 | 153 | def hcall_table_lookup(opcode): |
---|
152 | | - if (hcall_table.has_key(opcode)): |
---|
| 154 | + if (opcode in hcall_table): |
---|
153 | 155 | return hcall_table[opcode] |
---|
154 | 156 | else: |
---|
155 | 157 | return opcode |
---|
.. | .. |
---|
157 | 159 | print_ptrn = '%-28s%10s%10s%10s%10s' |
---|
158 | 160 | |
---|
159 | 161 | def trace_end(): |
---|
160 | | - print print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)') |
---|
161 | | - print '-' * 68 |
---|
| 162 | + print(print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)')) |
---|
| 163 | + print('-' * 68) |
---|
162 | 164 | for opcode in output: |
---|
163 | 165 | h_name = hcall_table_lookup(opcode) |
---|
164 | 166 | time = output[opcode]['time'] |
---|
.. | .. |
---|
166 | 168 | min_t = output[opcode]['min'] |
---|
167 | 169 | max_t = output[opcode]['max'] |
---|
168 | 170 | |
---|
169 | | - print print_ptrn % (h_name, cnt, min_t, max_t, time/cnt) |
---|
| 171 | + print(print_ptrn % (h_name, cnt, min_t, max_t, time//cnt)) |
---|
170 | 172 | |
---|
171 | 173 | def powerpc__hcall_exit(name, context, cpu, sec, nsec, pid, comm, callchain, |
---|
172 | 174 | opcode, retval): |
---|
173 | | - if (d_enter.has_key(cpu) and d_enter[cpu].has_key(opcode)): |
---|
| 175 | + if (cpu in d_enter and opcode in d_enter[cpu]): |
---|
174 | 176 | diff = nsecs(sec, nsec) - d_enter[cpu][opcode] |
---|
175 | 177 | |
---|
176 | | - if (output.has_key(opcode)): |
---|
| 178 | + if (opcode in output): |
---|
177 | 179 | output[opcode]['time'] += diff |
---|
178 | 180 | output[opcode]['cnt'] += 1 |
---|
179 | 181 | if (output[opcode]['min'] > diff): |
---|
.. | .. |
---|
190 | 192 | |
---|
191 | 193 | del d_enter[cpu][opcode] |
---|
192 | 194 | # else: |
---|
193 | | -# print "Can't find matching hcall_enter event. Ignoring sample" |
---|
| 195 | +# print("Can't find matching hcall_enter event. Ignoring sample") |
---|
194 | 196 | |
---|
195 | 197 | def powerpc__hcall_entry(event_name, context, cpu, sec, nsec, pid, comm, |
---|
196 | 198 | callchain, opcode): |
---|
197 | | - if (d_enter.has_key(cpu)): |
---|
| 199 | + if (cpu in d_enter): |
---|
198 | 200 | d_enter[cpu][opcode] = nsecs(sec, nsec) |
---|
199 | 201 | else: |
---|
200 | 202 | d_enter[cpu] = {opcode: nsecs(sec, nsec)} |
---|