diff options
author | Feng Tang <feng.tang@intel.com> | 2012-08-09 01:46:13 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-09 12:26:19 -0400 |
commit | 87b6a3ad40ba304ec468b972e979e7e410852476 (patch) | |
tree | bcd273478dd47106378b429e85a28d438d82a7e8 /tools/perf/scripts/python/event_analyzing_sample.py | |
parent | 0076d546b4f9b5c15121c6959d108a83fe43fa9a (diff) |
perf script python: Correct handler check and spelling errors
Correct the checking for handler returned by PyDict_GetItemString(),
also fix some spelling error and remove some data code in
event_analyzing_sample.py, as suggested by Namhyung Kim.
v2: restore back the wrongly removed trace_unhandled() func
Signed-off-by: Feng Tang <feng.tang@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20120809134613.067104c4@feng-i7
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/event_analyzing_sample.py')
-rw-r--r-- | tools/perf/scripts/python/event_analyzing_sample.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/tools/perf/scripts/python/event_analyzing_sample.py b/tools/perf/scripts/python/event_analyzing_sample.py index 46f05aad6d07..163c39fa12d9 100644 --- a/tools/perf/scripts/python/event_analyzing_sample.py +++ b/tools/perf/scripts/python/event_analyzing_sample.py | |||
@@ -1,15 +1,15 @@ | |||
1 | # process_event.py: general event handler in python | 1 | # event_analyzing_sample.py: general event handler in python |
2 | # | 2 | # |
3 | # Current perf report is alreay very powerful with the anotation integrated, | 3 | # Current perf report is already very powerful with the annotation integrated, |
4 | # and this script is not trying to be as powerful as perf report, but | 4 | # and this script is not trying to be as powerful as perf report, but |
5 | # providing end user/developer a flexible way to analyze the events other | 5 | # providing end user/developer a flexible way to analyze the events other |
6 | # than trace points. | 6 | # than trace points. |
7 | # | 7 | # |
8 | # The 2 database related functions in this script just show how to gather | 8 | # The 2 database related functions in this script just show how to gather |
9 | # the basic information, and users can modify and write their own functions | 9 | # the basic information, and users can modify and write their own functions |
10 | # according to their specific requirment. | 10 | # according to their specific requirement. |
11 | # | 11 | # |
12 | # The first sample "show_general_events" just does a baisc grouping for all | 12 | # The first function "show_general_events" just does a basic grouping for all |
13 | # generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is | 13 | # generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is |
14 | # for a x86 HW PMU event: PEBS with load latency data. | 14 | # for a x86 HW PMU event: PEBS with load latency data. |
15 | # | 15 | # |
@@ -85,7 +85,7 @@ def process_event(param_dict): | |||
85 | else: | 85 | else: |
86 | symbol = "Unknown_symbol" | 86 | symbol = "Unknown_symbol" |
87 | 87 | ||
88 | # Creat the event object and insert it to the right table in database | 88 | # Create the event object and insert it to the right table in database |
89 | event = create_event(name, comm, dso, symbol, raw_buf) | 89 | event = create_event(name, comm, dso, symbol, raw_buf) |
90 | insert_db(event) | 90 | insert_db(event) |
91 | 91 | ||
@@ -109,7 +109,7 @@ def trace_end(): | |||
109 | 109 | ||
110 | # | 110 | # |
111 | # As the event number may be very big, so we can't use linear way | 111 | # As the event number may be very big, so we can't use linear way |
112 | # to show the histgram in real number, but use a log2 algorithm. | 112 | # to show the histogram in real number, but use a log2 algorithm. |
113 | # | 113 | # |
114 | 114 | ||
115 | def num2sym(num): | 115 | def num2sym(num): |
@@ -130,18 +130,18 @@ def show_general_events(): | |||
130 | 130 | ||
131 | # Group by thread | 131 | # Group by thread |
132 | commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") | 132 | commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") |
133 | print "\n%16s %8s %16s\n%s" % ("comm", "number", "histgram", "="*42) | 133 | print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) |
134 | for row in commq: | 134 | for row in commq: |
135 | print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) | 135 | print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) |
136 | 136 | ||
137 | # Group by symbol | 137 | # Group by symbol |
138 | print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histgram", "="*58) | 138 | print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) |
139 | symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") | 139 | symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") |
140 | for row in symbolq: | 140 | for row in symbolq: |
141 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) | 141 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
142 | 142 | ||
143 | # Group by dso | 143 | # Group by dso |
144 | print "\n%40s %8s %16s\n%s" % ("dso", "number", "histgram", "="*74) | 144 | print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74) |
145 | dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") | 145 | dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") |
146 | for row in dsoq: | 146 | for row in dsoq: |
147 | print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) | 147 | print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) |
@@ -163,31 +163,27 @@ def show_pebs_ll(): | |||
163 | 163 | ||
164 | # Group by thread | 164 | # Group by thread |
165 | commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") | 165 | commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") |
166 | print "\n%16s %8s %16s\n%s" % ("comm", "number", "histgram", "="*42) | 166 | print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) |
167 | for row in commq: | 167 | for row in commq: |
168 | print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) | 168 | print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) |
169 | 169 | ||
170 | # Group by symbol | 170 | # Group by symbol |
171 | print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histgram", "="*58) | 171 | print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) |
172 | symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") | 172 | symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") |
173 | for row in symbolq: | 173 | for row in symbolq: |
174 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) | 174 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
175 | 175 | ||
176 | # Group by dse | 176 | # Group by dse |
177 | dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") | 177 | dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") |
178 | print "\n%32s %8s %16s\n%s" % ("dse", "number", "histgram", "="*58) | 178 | print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58) |
179 | for row in dseq: | 179 | for row in dseq: |
180 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) | 180 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
181 | 181 | ||
182 | # Group by latency | 182 | # Group by latency |
183 | latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") | 183 | latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") |
184 | print "\n%32s %8s %16s\n%s" % ("latency", "number", "histgram", "="*58) | 184 | print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58) |
185 | for row in latq: | 185 | for row in latq: |
186 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) | 186 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
187 | 187 | ||
188 | def trace_unhandled(event_name, context, event_fields_dict): | 188 | def trace_unhandled(event_name, context, event_fields_dict): |
189 | print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) | 189 | print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) |
190 | |||
191 | def print_header(event_name, cpu, secs, nsecs, pid, comm): | ||
192 | print "%-20s %5u %05u.%09u %8u %-20s " % \ | ||
193 | (event_name, cpu, secs, nsecs, pid, comm), | ||