From 2f134105ee9ae414ac99bc69365658da7d4d8643 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 11 Dec 2019 11:23:59 +0100 Subject: add basic workload energy/power/duration simulation tool --- bin/workload.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bin/workload.py diff --git a/bin/workload.py b/bin/workload.py new file mode 100755 index 0000000..ef89b0d --- /dev/null +++ b/bin/workload.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +from automata import PTA +import re +import sys +from utils import soft_cast_int, human_readable + +ptafile, raw_word = sys.argv[1:] + +pta = PTA.from_file(ptafile) + +trace = list() +for raw_symbol in raw_word.split(';'): + match = re.fullmatch(r' *([^(]+)\((.*)\) *', raw_symbol) + if match: + function_name = match.group(1).strip() + if match.group(2) == '': + raw_args = list() + else: + raw_args = match.group(2).split(',') + if function_name == 'sleep': + function_name = None + word = [function_name] + for raw_arg in raw_args: + word.append(soft_cast_int(raw_arg.strip())) + trace.append(word) + +print(trace) +result = pta.simulate(trace) + +print('Duration: ' + human_readable(result.duration, 's')) +print('Energy: ' + human_readable(result.energy, 'J')) +print('Mean Power: ' + human_readable(result.mean_power, 'W')) -- cgit v1.2.3