diff options
Diffstat (limited to 'tools/perf/scripts/python')
| -rw-r--r-- | tools/perf/scripts/python/event_analyzing_sample.py | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/tools/perf/scripts/python/event_analyzing_sample.py b/tools/perf/scripts/python/event_analyzing_sample.py index 2ec8915b74c5..aa1e2cfa26a6 100644 --- a/tools/perf/scripts/python/event_analyzing_sample.py +++ b/tools/perf/scripts/python/event_analyzing_sample.py | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | # for a x86 HW PMU event: PEBS with load latency data. | 15 | # for a x86 HW PMU event: PEBS with load latency data. |
| 16 | # | 16 | # |
| 17 | 17 | ||
| 18 | from __future__ import print_function | ||
| 19 | |||
| 18 | import os | 20 | import os |
| 19 | import sys | 21 | import sys |
| 20 | import math | 22 | import math |
| @@ -37,7 +39,7 @@ con = sqlite3.connect("/dev/shm/perf.db") | |||
| 37 | con.isolation_level = None | 39 | con.isolation_level = None |
| 38 | 40 | ||
| 39 | def trace_begin(): | 41 | def trace_begin(): |
| 40 | print "In trace_begin:\n" | 42 | print("In trace_begin:\n") |
| 41 | 43 | ||
| 42 | # | 44 | # |
| 43 | # Will create several tables at the start, pebs_ll is for PEBS data with | 45 | # Will create several tables at the start, pebs_ll is for PEBS data with |
| @@ -76,12 +78,12 @@ def process_event(param_dict): | |||
| 76 | name = param_dict["ev_name"] | 78 | name = param_dict["ev_name"] |
| 77 | 79 | ||
| 78 | # Symbol and dso info are not always resolved | 80 | # Symbol and dso info are not always resolved |
| 79 | if (param_dict.has_key("dso")): | 81 | if ("dso" in param_dict): |
| 80 | dso = param_dict["dso"] | 82 | dso = param_dict["dso"] |
| 81 | else: | 83 | else: |
| 82 | dso = "Unknown_dso" | 84 | dso = "Unknown_dso" |
| 83 | 85 | ||
| 84 | if (param_dict.has_key("symbol")): | 86 | if ("symbol" in param_dict): |
| 85 | symbol = param_dict["symbol"] | 87 | symbol = param_dict["symbol"] |
| 86 | else: | 88 | else: |
| 87 | symbol = "Unknown_symbol" | 89 | symbol = "Unknown_symbol" |
| @@ -102,7 +104,7 @@ def insert_db(event): | |||
| 102 | event.ip, event.status, event.dse, event.dla, event.lat)) | 104 | event.ip, event.status, event.dse, event.dla, event.lat)) |
| 103 | 105 | ||
| 104 | def trace_end(): | 106 | def trace_end(): |
| 105 | print "In trace_end:\n" | 107 | print("In trace_end:\n") |
| 106 | # We show the basic info for the 2 type of event classes | 108 | # We show the basic info for the 2 type of event classes |
| 107 | show_general_events() | 109 | show_general_events() |
| 108 | show_pebs_ll() | 110 | show_pebs_ll() |
| @@ -123,29 +125,29 @@ def show_general_events(): | |||
| 123 | # Check the total record number in the table | 125 | # Check the total record number in the table |
| 124 | count = con.execute("select count(*) from gen_events") | 126 | count = con.execute("select count(*) from gen_events") |
| 125 | for t in count: | 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 | if t[0] == 0: | 129 | if t[0] == 0: |
| 128 | return | 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 | # Group by thread | 134 | # Group by thread |
| 133 | commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") | 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 | for row in commq: | 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 | # Group by symbol | 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 | symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") | 142 | symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") |
| 141 | for row in symbolq: | 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 | # Group by dso | 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 | dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") | 148 | dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") |
| 147 | for row in dsoq: | 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 | # This function just shows the basic info, and we could do more with the | 153 | # This function just shows the basic info, and we could do more with the |
| @@ -156,35 +158,35 @@ def show_pebs_ll(): | |||
| 156 | 158 | ||
| 157 | count = con.execute("select count(*) from pebs_ll") | 159 | count = con.execute("select count(*) from pebs_ll") |
| 158 | for t in count: | 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 | if t[0] == 0: | 162 | if t[0] == 0: |
| 161 | return | 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 | # Group by thread | 167 | # Group by thread |
| 166 | commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") | 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 | for row in commq: | 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 | # Group by symbol | 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 | symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") | 175 | symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") |
| 174 | for row in symbolq: | 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 | # Group by dse | 179 | # Group by dse |
| 178 | dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") | 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 | for row in dseq: | 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 | # Group by latency | 185 | # Group by latency |
| 184 | latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") | 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 | for row in latq: | 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 | def trace_unhandled(event_name, context, event_fields_dict): | 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())])) |
