summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-13 10:58:56 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-13 10:58:56 +0100
commit0c132a304eb001dcd7ff9ee578854c92686fe15b (patch)
tree156615f7ffb4b9dc36fe5a648d5b919a836bc801 /lib
parent28d33c2006b88c40d9ff068f2ea3baa8ed6db44f (diff)
WiP
Diffstat (limited to 'lib')
-rwxr-xr-xlib/dfatool.py40
-rw-r--r--lib/harness.py27
2 files changed, 28 insertions, 39 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index a089c1d..297cd71 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -1134,6 +1134,8 @@ class AnalyticModel:
def _add_trace_data_to_aggregate(aggregate, key, element):
+ # Only cares about element['isa'], element['offline_aggregates'], and
+ # element['plan']['level']
if not key in aggregate:
aggregate[key] = {
'isa' : element['isa']
@@ -1143,6 +1145,7 @@ def _add_trace_data_to_aggregate(aggregate, key, element):
if element['isa'] == 'state':
aggregate[key]['attributes'] = ['power']
else:
+ # TODO do not hardcode values
aggregate[key]['attributes'] = ['duration', 'energy', 'rel_energy_prev', 'rel_energy_next']
if element['plan']['level'] == 'epilogue':
aggregate[key]['attributes'].insert(0, 'timeout')
@@ -1162,16 +1165,6 @@ def pta_trace_to_aggregate(traces, ignore_trace_indexes = []):
- name: str Name
- isa: str state // transition
- parameter: { ... globaler Parameter: aktueller wert. null falls noch nicht eingestellt }
- - plan:
- Falls isa == 'state':
- - power: int(uW?)
- - time: int(us) geplante Dauer
- - energy: int(pJ?)
- Falls isa == 'transition':
- - timeout: int(us) oder null
- - energy: int (pJ?)
- - level: str 'user' 'epilogue'
- - offline_attributes: [ ... Namen der in offline_aggregates gespeicherten Modellattribute, z.B. param, duration, energy, timeout ]
- offline_aggregates:
- power: [float(uW)] Mittlere Leistung während Zustand/Transitions
- power_std: [float(uW^2)] Standardabweichung der Leistung
@@ -1184,33 +1177,6 @@ def pta_trace_to_aggregate(traces, ignore_trace_indexes = []):
- timeout: [int(us)] Dauer des vorherigen Zustands
- rel_energy_prev: [int(pJ)]
- rel_energy_next: [int(pJ)]
- - offline: [ ... Während der Messung von MIMOSA o.ä. gemessene Werte
- -> siehe doc/MIMOSA analyze_states
- - isa: 'state' oder 'transition'
- - clip_rate: range(0..1) Anteil an Clipping im Energieverbrauch
- - raw_mean: Mittelwert der Rohwerte
- - raw_std: Standardabweichung der Rohwerte
- - uW_mean: Mittelwert der (kalibrierten) Leistungsaufnahme
- - uW_std: Standardabweichung der (kalibrierten) Leistungsaufnahme
- - us: Dauer
- Nur falls isa 'transition':
- - timeout: Dauer des vorherigen Zustands
- - uW_mean_delta_prev
- - uW_mean_delta_next
- ]
- - online: [ ... Während der Messung vom Betriebssystem bestimmte Daten
- Falls isa == 'state':
- - power: int(uW?)
- - time: int(us) geplante Dauer
- - energy: int(pJ?)
- Falls isa == 'transition':
- - timeout: int(us) oder null
- - energy: int (pJ?)
- - level: str ('user' oder 'epilogue')
- ]
- Falls isa == 'transition':
- - code: [str] Name und Argumente der aufgerufenen Funktion
- - args: [str] Argumente der aufgerufenen Funktion
]
]
ignore_trace_indexes -- list of trace indexes. The corresponding taces will be ignored.
diff --git a/lib/harness.py b/lib/harness.py
index 1eb294b..2705193 100644
--- a/lib/harness.py
+++ b/lib/harness.py
@@ -4,9 +4,15 @@ Harnesses for various types of benchmark logs.
tbd
"""
+# TODO prepare benchmark log JSON with parameters etc.
+# Should be independent of PTA class, as benchmarks may also be
+# generated otherwise and it should also work with AnalyticModel (which does
+# not have states)
class TransitionHarness:
def __init__(self, gpio_pin = None):
self.gpio_pin = gpio_pin
+ self.traces = []
+ self.trace_id = 1
pass
def global_code(self):
@@ -23,10 +29,27 @@ class TransitionHarness:
def start_benchmark(self):
return 'ptalog.startBenchmark(0);\n'
+ def start_trace(self):
+ self.traces.append({
+ 'id' : self.trace_id,
+ 'trace' : [{
+ 'name' : 'UNINITIALIZED',
+ 'isa' : 'state',
+ 'parameter' : dict(),
+ 'offline_aggregates' : list(),
+ }]
+ })
+ self.trace_id += 1
+
+ #def append_state(self):
+
+ #def append_transition(self, ):
+
def start_run(self):
+ self.start_trace()
return 'ptalog.reset();\n'
- def pass_transition(self, transition_id, transition_code):
+ def pass_transition(self, transition_id, transition_code, parameter = dict()):
ret = 'ptalog.passTransition({:d});\n'.format(transition_id)
ret += 'ptalog.startTransition();\n'
ret += '{}\n'.format(transition_code)
@@ -56,7 +79,7 @@ class OnboardTimerHarness(TransitionHarness):
ret += super().start_benchmark()
return ret
- def pass_transition(self, transition_id, transition_code):
+ def pass_transition(self, transition_id, transition_code, parameter = dict()):
ret = 'ptalog.passTransition({:d});\n'.format(transition_id)
ret += 'ptalog.startTransition();\n'
ret += 'counter.start();\n'