Skip to content

tools/perf/scripts: Fixed pylint warnings on stat_cpi.py #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -2,65 +2,78 @@

from __future__ import print_function

data = {}
times = []
threads = []
cpus = []
DATA = {}
TIMES = []
THREADS = []
CPUS = []


def get_key(time, event, cpu, thread):
return "%d-%s-%d-%d" % (time, event, cpu, thread)


def store_key(time, cpu, thread):
if (time not in times):
times.append(time)
if time not in TIMES:
TIMES.append(time)

if cpu not in CPUS:
CPUS.append(cpu)

if (cpu not in cpus):
cpus.append(cpu)
if thread not in THREADS:
THREADS.append(thread)

if (thread not in threads):
threads.append(thread)

def store(time, event, cpu, thread, val, ena, run):
#print("event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" %
# print("event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" %
# (event, cpu, thread, time, val, ena, run))

store_key(time, cpu, thread)
key = get_key(time, event, cpu, thread)
data[key] = [ val, ena, run]
DATA[key] = [val, ena, run]


def get(time, event, cpu, thread):
key = get_key(time, event, cpu, thread)
return data[key][0]
return DATA[key][0]


def stat__cycles_k(cpu, thread, time, val, ena, run):
store(time, "cycles", cpu, thread, val, ena, run);
store(time, "cycles", cpu, thread, val, ena, run)


def stat__instructions_k(cpu, thread, time, val, ena, run):
store(time, "instructions", cpu, thread, val, ena, run);
store(time, "instructions", cpu, thread, val, ena, run)


def stat__cycles_u(cpu, thread, time, val, ena, run):
store(time, "cycles", cpu, thread, val, ena, run);
store(time, "cycles", cpu, thread, val, ena, run)


def stat__instructions_u(cpu, thread, time, val, ena, run):
store(time, "instructions", cpu, thread, val, ena, run);
store(time, "instructions", cpu, thread, val, ena, run)


def stat__cycles(cpu, thread, time, val, ena, run):
store(time, "cycles", cpu, thread, val, ena, run);
store(time, "cycles", cpu, thread, val, ena, run)


def stat__instructions(cpu, thread, time, val, ena, run):
store(time, "instructions", cpu, thread, val, ena, run);
store(time, "instructions", cpu, thread, val, ena, run)


def stat__interval(time):
for cpu in cpus:
for thread in threads:
for cpu in CPUS:
for thread in THREADS:
cyc = get(time, "cycles", cpu, thread)
ins = get(time, "instructions", cpu, thread)
cpi = 0

if ins != 0:
cpi = cyc/float(ins)

print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins))
print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" %
(time/(float(1000000000)), cpu, thread, cpi, cyc, ins))


def trace_end():
pass