Commit b1b71c79 authored by Florian Fischer's avatar Florian Fischer
Browse files

please pylint by not using global for the perf energy events

parent 60472aa9
Pipeline #80765 passed with stage
in 1 minute and 13 seconds
......@@ -20,7 +20,23 @@ DDD_EVENTS = DD_EVENTS + ',L1-dcache-prefetches,L1-dcache-prefetch-misses'
PERF_RECORD_CMD = f'{PERF_EXE} record --call-graph dwarf -o {{output}} -p {{pid}}'
PERF_STAT_CMD = f'{PERF_EXE} stat -e {{events}} record -o {{output}} -p {{pid}}'
ENERGY_EVENTS=''
def get_perf_energy_events(remote_cmd=None):
"""Get the list of available energy events on this system"""
if not get_perf_energy_events.events:
perf_list_cmd = 'perf list'
if remote_cmd:
perf_list_cmd = f'{remote_cmd} {perf_list_cmd}'
get_perf_energy_events.events = ','.join([
l.split()[0] for l in subprocess.check_output(
perf_list_cmd.split(), text=True).splitlines() if 'energy' in l
])
return get_perf_energy_events.events
get_perf_energy_events.events = '' # type: ignore
PERF_ENERGY_CMD = f'{PERF_EXE} stat -a -x, -e {{energy_events}} -o {{output}}'
PERF_RECORD_OUTPUT = '{run}_perf_record.data'
......@@ -92,20 +108,7 @@ class TrackEnergy(subprocess.Popen):
stat_out = bench_dir / PERF_ENERGY_OUTPUT.format(arg_prefix=arg_prefix)
# Get the available energy events on the host
global ENERGY_EVENTS
if not ENERGY_EVENTS:
perf_list_cmd = 'perf list'
if remote_cmd:
perf_list_cmd = f'{remote_cmd} {perf_list_cmd}'
ENERGY_EVENTS = ','.join([
l.split()[0]
for l in subprocess.check_output(perf_list_cmd.split(),
text=True).splitlines()
if 'energy' in l
])
energy_events = ENERGY_EVENTS
energy_events = get_perf_energy_events(remote_cmd=remote_cmd)
cmd = PERF_ENERGY_CMD.format(output=stat_out,
energy_events=energy_events)
......@@ -128,7 +131,9 @@ class TrackEnergy(subprocess.Popen):
kill_cmd = ['pkill', '-INT', '-f', f'{self.bin} stat']
if self.remote_cmd:
# wrap the command line in "" to prevent it from being word split on the host
kill_cmd = f'{self.remote_cmd}'.split() + kill_cmd[:-1] + [f'"{kill_cmd[-1]}"']
kill_cmd = f'{self.remote_cmd}'.split() + kill_cmd[:-1] + [
f'"{kill_cmd[-1]}"'
]
log.debug('kill perf energy tracking process using %s',
' '.join(kill_cmd))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment