diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-29 10:06:12 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-29 10:06:12 +0100 |
commit | c5ec741a258577386f30ad2577141ce498f6310c (patch) | |
tree | 143954985bf223b06bbeb9d8c27d64d18a52c706 | |
parent | 8b6735c64b48153c5bf39536489834174edbd334 (diff) |
argument-aware analysis of protocolmodeling cycles benchmarks
-rwxr-xr-x | lib/dfatool.py | 15 | ||||
-rwxr-xr-x | lib/protocol_benchmarks.py | 23 |
2 files changed, 27 insertions, 11 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py index 5af6cc8..d998dbb 100755 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -888,6 +888,13 @@ def _try_fits(by_param, state_or_tran, model_attribute, param_index, safe_functi 'results' : results } +def _num_args_from_by_name(by_name): + num_args = dict() + for key, value in by_name.items(): + if 'args' in value: + num_args[key] = len(value['args'][0]) + return num_args + class AnalyticModel: u""" Parameter-aware analytic energy/data size/... model. @@ -941,8 +948,9 @@ class AnalyticModel: self.names = sorted(by_name.keys()) self.parameters = sorted(parameters) self.verbose = verbose + self._num_args = _num_args_from_by_name(by_name) - self.stats = ParamStats(self.by_name, self.by_param, self.parameters, {}, verbose = verbose) + self.stats = ParamStats(self.by_name, self.by_param, self.parameters, self._num_args, verbose = verbose) def _fit(self): paramfit = ParallelParamFit(self.by_param) @@ -1124,6 +1132,10 @@ class AnalyticModel: 'by_name' : detailed_results, } + def to_json(self): + # TODO + pass + def _add_trace_data_to_aggregate(aggregate, key, element): # Only cares about element['isa'], element['offline_aggregates'], and @@ -1157,6 +1169,7 @@ 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 } + - args: [ Funktionsargumente, falls isa == 'transition' ] - offline_aggregates: - power: [float(uW)] Mittlere Leistung während Zustand/Transitions - power_std: [float(uW^2)] Standardabweichung der Leistung diff --git a/lib/protocol_benchmarks.py b/lib/protocol_benchmarks.py index 6220b94..b7af4f7 100755 --- a/lib/protocol_benchmarks.py +++ b/lib/protocol_benchmarks.py @@ -1354,25 +1354,28 @@ def shorten_call(snippet, lib = ''): # mpack_start_array(&writer, x) -> mpack_start_array(&writer elif 'mpack_start_' in snippet: snippet = snippet.split(',')[0] - elif 'bout <<' in snippet: - if '\\":\\"' in snippet: - snippet = 'bout << key:str' - elif 'bout << "\\"' in snippet: - snippet = 'bout << key' - else: - snippet = 'bout << other' + #elif 'bout <<' in snippet: + # if '\\":\\"' in snippet: + # snippet = 'bout << key:str' + # elif 'bout << "\\"' in snippet: + # snippet = 'bout << key' + # else: + # snippet = 'bout << other' elif 'msg.' in snippet: snippet = re.sub('msg.(?:[^[]+)(?:\[.*?\])? = .*', 'msg.? = ?', snippet) elif lib == 'arduinojson:': - snippet = re.sub('ArduinoJson::JsonObject& [^ ]+ = [^.]+.createNestedObject\([^)]*\);', 'ArduinoJson::JsonObject& ? = ?.createNestedObject(?);', snippet) - snippet = re.sub('ArduinoJson::JsonArray& [^ ]+ = [^.]+.createNestedArray\([^)]*\);', 'ArduinoJson::JsonArray& ? = ?.createNestedArray(?);', snippet) + snippet = re.sub('ArduinoJson::JsonObject& [^ ]+ = [^.]+.createNestedObject\([^")]*\);', 'ArduinoJson::JsonObject& ? = ?.createNestedObject();', snippet) + snippet = re.sub('ArduinoJson::JsonObject& [^ ]+ = [^.]+.createNestedObject\("[^")]*"\);', 'ArduinoJson::JsonObject& ? = ?.createNestedObject(?);', snippet) + snippet = re.sub('ArduinoJson::JsonArray& [^ ]+ = [^.]+.createNestedArray\([^")]*\);', 'ArduinoJson::JsonArray& ? = ?.createNestedArray();', snippet) + snippet = re.sub('ArduinoJson::JsonArray& [^ ]+ = [^.]+.createNestedArray\("[^")]*"\);', 'ArduinoJson::JsonArray& ? = ?.createNestedArray(?);', snippet) snippet = re.sub('root[^[]*\["[^"]*"\] = [^";]+', 'root?["?"] = ?', snippet) snippet = re.sub('root[^[]*\["[^"]*"\] = "[^"]+"', 'root?["?"] = "?"', snippet) snippet = re.sub('rootl.add\([^)]*\)', 'rootl.add(?)', snippet) snippet = re.sub('^dec_[^ ]*', 'dec_?', snippet) if lib == 'arduinojson:': - snippet = re.sub('root[^. ]+\.as', 'root[?].as', snippet) + snippet = re.sub('root[^[]*\[[^]"]+\]\.as', 'root[?].as', snippet) + snippet = re.sub('root[^[]*\["[^]]+"\]\.as', 'root["?"].as', snippet) elif 'nanopb:' in lib: snippet = re.sub('= msg\.[^;]+;', '= msg.?;', snippet) elif lib == 'mpack:': |