| .. | .. |
|---|
| 15 | 15 | # for a x86 HW PMU event: PEBS with load latency data. |
|---|
| 16 | 16 | # |
|---|
| 17 | 17 | |
|---|
| 18 | +from __future__ import print_function |
|---|
| 19 | + |
|---|
| 18 | 20 | import os |
|---|
| 19 | 21 | import sys |
|---|
| 20 | 22 | import math |
|---|
| .. | .. |
|---|
| 37 | 39 | con.isolation_level = None |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | def trace_begin(): |
|---|
| 40 | | - print "In trace_begin:\n" |
|---|
| 42 | + print("In trace_begin:\n") |
|---|
| 41 | 43 | |
|---|
| 42 | 44 | # |
|---|
| 43 | 45 | # Will create several tables at the start, pebs_ll is for PEBS data with |
|---|
| .. | .. |
|---|
| 76 | 78 | name = param_dict["ev_name"] |
|---|
| 77 | 79 | |
|---|
| 78 | 80 | # Symbol and dso info are not always resolved |
|---|
| 79 | | - if (param_dict.has_key("dso")): |
|---|
| 81 | + if ("dso" in param_dict): |
|---|
| 80 | 82 | dso = param_dict["dso"] |
|---|
| 81 | 83 | else: |
|---|
| 82 | 84 | dso = "Unknown_dso" |
|---|
| 83 | 85 | |
|---|
| 84 | | - if (param_dict.has_key("symbol")): |
|---|
| 86 | + if ("symbol" in param_dict): |
|---|
| 85 | 87 | symbol = param_dict["symbol"] |
|---|
| 86 | 88 | else: |
|---|
| 87 | 89 | symbol = "Unknown_symbol" |
|---|
| .. | .. |
|---|
| 102 | 104 | event.ip, event.status, event.dse, event.dla, event.lat)) |
|---|
| 103 | 105 | |
|---|
| 104 | 106 | def trace_end(): |
|---|
| 105 | | - print "In trace_end:\n" |
|---|
| 107 | + print("In trace_end:\n") |
|---|
| 106 | 108 | # We show the basic info for the 2 type of event classes |
|---|
| 107 | 109 | show_general_events() |
|---|
| 108 | 110 | show_pebs_ll() |
|---|
| .. | .. |
|---|
| 123 | 125 | # Check the total record number in the table |
|---|
| 124 | 126 | count = con.execute("select count(*) from gen_events") |
|---|
| 125 | 127 | for t in count: |
|---|
| 126 | | - print "There is %d records in gen_events table" % t[0] |
|---|
| 128 | + print("There is %d records in gen_events table" % t[0]) |
|---|
| 127 | 129 | if t[0] == 0: |
|---|
| 128 | 130 | return |
|---|
| 129 | 131 | |
|---|
| 130 | | - print "Statistics about the general events grouped by thread/symbol/dso: \n" |
|---|
| 132 | + print("Statistics about the general events grouped by thread/symbol/dso: \n") |
|---|
| 131 | 133 | |
|---|
| 132 | 134 | # Group by thread |
|---|
| 133 | 135 | commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") |
|---|
| 134 | | - print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) |
|---|
| 136 | + print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)) |
|---|
| 135 | 137 | for row in commq: |
|---|
| 136 | | - print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 138 | + print("%16s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 137 | 139 | |
|---|
| 138 | 140 | # Group by symbol |
|---|
| 139 | | - print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) |
|---|
| 141 | + print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)) |
|---|
| 140 | 142 | symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") |
|---|
| 141 | 143 | for row in symbolq: |
|---|
| 142 | | - print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 144 | + print("%32s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 143 | 145 | |
|---|
| 144 | 146 | # Group by dso |
|---|
| 145 | | - print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74) |
|---|
| 147 | + print("\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74)) |
|---|
| 146 | 148 | dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") |
|---|
| 147 | 149 | for row in dsoq: |
|---|
| 148 | | - print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 150 | + print("%40s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 149 | 151 | |
|---|
| 150 | 152 | # |
|---|
| 151 | 153 | # This function just shows the basic info, and we could do more with the |
|---|
| .. | .. |
|---|
| 156 | 158 | |
|---|
| 157 | 159 | count = con.execute("select count(*) from pebs_ll") |
|---|
| 158 | 160 | for t in count: |
|---|
| 159 | | - print "There is %d records in pebs_ll table" % t[0] |
|---|
| 161 | + print("There is %d records in pebs_ll table" % t[0]) |
|---|
| 160 | 162 | if t[0] == 0: |
|---|
| 161 | 163 | return |
|---|
| 162 | 164 | |
|---|
| 163 | | - print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n" |
|---|
| 165 | + print("Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n") |
|---|
| 164 | 166 | |
|---|
| 165 | 167 | # Group by thread |
|---|
| 166 | 168 | commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") |
|---|
| 167 | | - print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) |
|---|
| 169 | + print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)) |
|---|
| 168 | 170 | for row in commq: |
|---|
| 169 | | - print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 171 | + print("%16s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 170 | 172 | |
|---|
| 171 | 173 | # Group by symbol |
|---|
| 172 | | - print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) |
|---|
| 174 | + print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)) |
|---|
| 173 | 175 | symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") |
|---|
| 174 | 176 | for row in symbolq: |
|---|
| 175 | | - print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 177 | + print("%32s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 176 | 178 | |
|---|
| 177 | 179 | # Group by dse |
|---|
| 178 | 180 | dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") |
|---|
| 179 | | - print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58) |
|---|
| 181 | + print("\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58)) |
|---|
| 180 | 182 | for row in dseq: |
|---|
| 181 | | - print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 183 | + print("%32s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 182 | 184 | |
|---|
| 183 | 185 | # Group by latency |
|---|
| 184 | 186 | latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") |
|---|
| 185 | | - print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58) |
|---|
| 187 | + print("\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58)) |
|---|
| 186 | 188 | for row in latq: |
|---|
| 187 | | - print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
|---|
| 189 | + print("%32s %8d %s" % (row[0], row[1], num2sym(row[1]))) |
|---|
| 188 | 190 | |
|---|
| 189 | 191 | def trace_unhandled(event_name, context, event_fields_dict): |
|---|
| 190 | | - print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) |
|---|
| 192 | + print (' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])) |
|---|