summaryrefslogtreecommitdiff
path: root/bin/workload.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-05-28 12:04:37 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-05-28 12:04:37 +0200
commitc69331e4d925658b2bf26dcb387981f6530d7b9e (patch)
treed19c7f9b0bf51f68c104057e013630e009835268 /bin/workload.py
parent23927051ac3e64cabbaa6c30e8356dfe90ebfa6c (diff)
use black(1) for uniform code formatting
Diffstat (limited to 'bin/workload.py')
-rwxr-xr-xbin/workload.py58
1 files changed, 43 insertions, 15 deletions
diff --git a/bin/workload.py b/bin/workload.py
index 6199394..19a7378 100755
--- a/bin/workload.py
+++ b/bin/workload.py
@@ -13,30 +13,50 @@ loop_names = set()
def simulate_word(timedword):
- prev_state = 'UNINITIALIZED'
+ prev_state = "UNINITIALIZED"
prev_param = None
ret = dict()
for trace_part in timedword:
- print('Trace Part {}'.format(trace_part))
+ print("Trace Part {}".format(trace_part))
if type(trace_part) is TimedWord:
- result = pta.simulate(trace_part, orig_state=prev_state, orig_param=prev_param)
+ result = pta.simulate(
+ trace_part, orig_state=prev_state, orig_param=prev_param
+ )
elif type(trace_part) is Workload:
- result = pta.simulate(trace_part.word, orig_state=prev_state, orig_param=prev_param)
+ result = pta.simulate(
+ trace_part.word, orig_state=prev_state, orig_param=prev_param
+ )
if prev_state != result.end_state:
- print('Warning: loop starts in state {}, but terminates in {}'.format(prev_state, result.end_state.name))
+ print(
+ "Warning: loop starts in state {}, but terminates in {}".format(
+ prev_state, result.end_state.name
+ )
+ )
if prev_param != result.parameters:
- print('Warning: loop starts with parameters {}, but terminates with {}'.format(prev_param, result.parameters))
+ print(
+ "Warning: loop starts with parameters {}, but terminates with {}".format(
+ prev_param, result.parameters
+ )
+ )
ret[trace_part.name] = result
loop_names.add(trace_part.name)
- print(' Duration: ' + human_readable(result.duration, 's'))
+ print(" Duration: " + human_readable(result.duration, "s"))
if result.duration_mae:
- print(u' ± {} / {:.0f}%'.format(human_readable(result.duration_mae, 's'), result.duration_mape))
- print(' Energy: ' + human_readable(result.energy, 'J'))
+ print(
+ u" ± {} / {:.0f}%".format(
+ human_readable(result.duration_mae, "s"), result.duration_mape
+ )
+ )
+ print(" Energy: " + human_readable(result.energy, "J"))
if result.energy_mae:
- print(u' ± {} / {:.0f}%'.format(human_readable(result.energy_mae, 'J'), result.energy_mape))
- print(' Mean Power: ' + human_readable(result.mean_power, 'W'))
- print('')
+ print(
+ u" ± {} / {:.0f}%".format(
+ human_readable(result.energy_mae, "J"), result.energy_mape
+ )
+ )
+ print(" Mean Power: " + human_readable(result.mean_power, "W"))
+ print("")
prev_state = result.end_state
prev_param = result.parameters
@@ -49,7 +69,7 @@ for i in range(len(args) // 2):
ptafiles.append(ptafile)
pta = PTA.from_file(ptafile)
timedword = TimedSequence(raw_word)
- print('Input: {}\n'.format(timedword))
+ print("Input: {}\n".format(timedword))
loops[ptafile] = simulate_word(timedword)
for loop_name in sorted(loop_names):
@@ -59,6 +79,14 @@ for loop_name in sorted(loop_names):
if loop_name in loops[ptafile]:
result_set.append(loops[ptafile][loop_name])
total_power += loops[ptafile][loop_name].mean_power
- print('{}: total mean power is {}'.format(loop_name, human_readable(total_power, 'W')))
+ print(
+ "{}: total mean power is {}".format(loop_name, human_readable(total_power, "W"))
+ )
for i, result in enumerate(result_set):
- print(' {:.0f}% {} (period: {})'.format(result.mean_power * 100 / total_power, ptafiles[i], human_readable(result.duration, 's')))
+ print(
+ " {:.0f}% {} (period: {})".format(
+ result.mean_power * 100 / total_power,
+ ptafiles[i],
+ human_readable(result.duration, "s"),
+ )
+ )