23 sys.path.append(os.environ[
'PERF_EXEC_PATH'] + \
24 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
26 from perf_trace_context
import *
27 from EventClass
import *
35 con = sqlite3.connect(
"/dev/shm/perf.db")
36 con.isolation_level =
None
39 print "In trace_begin:\n"
46 create table if not exists gen_events (
53 create table if not exists pebs_ll (
71 event_attr = param_dict[
"attr"]
72 sample = param_dict[
"sample"]
73 raw_buf = param_dict[
"raw_buf"]
74 comm = param_dict[
"comm"]
75 name = param_dict[
"ev_name"]
78 if (param_dict.has_key(
"dso")):
79 dso = param_dict[
"dso"]
83 if (param_dict.has_key(
"symbol")):
84 symbol = param_dict[
"symbol"]
86 symbol =
"Unknown_symbol"
89 event = create_event(name, comm, dso, symbol, raw_buf)
93 if event.ev_type == EVTYPE_GENERIC:
94 con.execute(
"insert into gen_events values(?, ?, ?, ?)",
95 (event.name, event.symbol, event.comm, event.dso))
96 elif event.ev_type == EVTYPE_PEBS_LL:
97 event.ip &= 0x7fffffffffffffff
98 event.dla &= 0x7fffffffffffffff
99 con.execute(
"insert into pebs_ll values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
100 (event.name, event.symbol, event.comm, event.dso, event.flags,
101 event.ip, event.status, event.dse, event.dla, event.lat))
104 print "In trace_end:\n"
117 snum =
'#' * (int)(math.log(num, 2) + 1)
123 count = con.execute(
"select count(*) from gen_events")
125 print "There is %d records in gen_events table" % t[0]
129 print "Statistics about the general events grouped by thread/symbol/dso: \n"
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",
"histogram",
"="*42)
135 print "%16s %8d %s" % (row[0], row[1],
num2sym(row[1]))
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)")
141 print "%32s %8d %s" % (row[0], row[1],
num2sym(row[1]))
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)")
147 print "%40s %8d %s" % (row[0], row[1],
num2sym(row[1]))
156 count = con.execute(
"select count(*) from pebs_ll")
158 print "There is %d records in pebs_ll table" % t[0]
162 print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n"
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",
"histogram",
"="*42)
168 print "%16s %8d %s" % (row[0], row[1],
num2sym(row[1]))
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)")
174 print "%32s %8d %s" % (row[0], row[1],
num2sym(row[1]))
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",
"histogram",
"="*58)
180 print "%32s %8d %s" % (row[0], row[1],
num2sym(row[1]))
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",
"histogram",
"="*58)
186 print "%32s %8d %s" % (row[0], row[1],
num2sym(row[1]))
189 print ' '.join([
'%s=%s'%(k,
str(v))
for k,v
in sorted(event_fields_dict.items())])