summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-02-02 16:38:00 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-02-02 16:38:00 +0100
commit9535cca7a916d0ffd180e569079ceaf2e8a8f47a (patch)
tree30245dcaf1e31c9b4569d34066518ee3b4b470cf /bin
parent579a1fd9c3d2809cc1d5a017e7f1e681e014758b (diff)
analyze-log, analyze-kconfig: preliminary --load-json support
Diffstat (limited to 'bin')
-rwxr-xr-xbin/analyze-kconfig.py38
-rwxr-xr-xbin/analyze-log.py50
2 files changed, 50 insertions, 38 deletions
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index f65751e..c369c05 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -325,14 +325,18 @@ def main():
max_std = None
ts = time.time()
- model = AnalyticModel(
- by_name,
- parameter_names,
- force_tree=args.force_tree,
- max_std=max_std,
- compute_stats=not args.skip_param_stats,
- function_override=function_override,
- )
+ if args.load_json:
+ with open(args.load_json, "r") as f:
+ model = AnalyticModel.from_json(json.load(f), by_name, parameter_names)
+ else:
+ model = AnalyticModel(
+ by_name,
+ parameter_names,
+ force_tree=args.force_tree,
+ max_std=max_std,
+ compute_stats=not args.skip_param_stats,
+ function_override=function_override,
+ )
timing["AnalyticModel"] = time.time() - ts
if not model.names:
@@ -444,22 +448,16 @@ def main():
static_quality = model.assess(static_model)
timing["assess static"] = time.time() - ts
- try:
- ts = time.time()
- lut_model = model.get_param_lut()
- timing["get lut"] = time.time() - ts
+ ts = time.time()
+ lut_model = model.get_param_lut()
+ timing["get lut"] = time.time() - ts
+ if lut_model is None:
+ lut_quality = None
+ else:
ts = time.time()
lut_quality = model.assess(lut_model)
timing["assess lut"] = time.time() - ts
- except RuntimeError as e:
- if args.force_tree:
- # this is to be expected
- logging.debug(f"Skipping LUT model: {e}")
- else:
- logging.warning(f"Skipping LUT model: {e}")
- lut_model = None
- lut_quality = None
if args.export_csv:
for name in model.names:
diff --git a/bin/analyze-log.py b/bin/analyze-log.py
index 90c658c..988d92f 100755
--- a/bin/analyze-log.py
+++ b/bin/analyze-log.py
@@ -15,8 +15,9 @@ from dfatool.validation import CrossValidator
from functools import reduce
import logging
import json
-import sys
import re
+import sys
+import time
def parse_logfile(filename):
@@ -32,6 +33,7 @@ def parse_logfile(filename):
def main():
+ timing = dict()
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__
)
@@ -96,13 +98,19 @@ def main():
state_or_tran, attribute, function_str = function_desc.split(":")
function_override[(state_or_tran, attribute)] = function_str
- model = AnalyticModel(
- by_name,
- parameter_names,
- force_tree=args.force_tree,
- compute_stats=not args.skip_param_stats,
- function_override=function_override,
- )
+ ts = time.time()
+ if args.load_json:
+ with open(args.load_json, "r") as f:
+ model = AnalyticModel.from_json(json.load(f), by_name, parameter_names)
+ else:
+ model = AnalyticModel(
+ by_name,
+ parameter_names,
+ force_tree=args.force_tree,
+ compute_stats=not args.skip_param_stats,
+ function_override=function_override,
+ )
+ timing["AnalyticModel"] = time.time() - ts
if args.info:
dfatool.cli.print_info_by_name(model, by_name)
@@ -170,20 +178,23 @@ def main():
xv_count = None
static_model = model.get_static()
- try:
- lut_model = model.get_param_lut()
- lut_quality = model.assess(lut_model)
- except RuntimeError as e:
- if args.force_tree:
- # this is to be expected
- logging.debug(f"Skipping LUT model: {e}")
- else:
- logging.warning(f"Skipping LUT model: {e}")
- lut_model = None
+
+ ts = time.time()
+ lut_model = model.get_param_lut()
+ timing["get lut"] = time.time() - ts
+
+ if lut_model is None:
lut_quality = None
+ else:
+ ts = time.time()
+ lut_quality = model.assess(lut_model)
+ timing["assess lut"] = time.time() - ts
+ ts = time.time()
param_model, param_info = model.get_fitted()
+ timing["get model"] = time.time() - ts
+ ts = time.time()
if xv_method == "montecarlo":
static_quality, _ = xv.montecarlo(
lambda m: m.get_static(), xv_count, static=True
@@ -202,6 +213,7 @@ def main():
json.dump(raw_results, f, cls=dfatool.utils.NpEncoder)
else:
analytic_quality = model.assess(param_model)
+ timing["assess model"] = time.time() - ts
if "static" in args.show_model or "all" in args.show_model:
print("--- static model ---")
@@ -251,6 +263,8 @@ def main():
if args.export_dref:
dref = model.to_dref(static_quality, lut_quality, analytic_quality)
+ for key, value in timing.items():
+ dref[f"timing/{key}"] = (value, r"\second")
dfatool.cli.export_dataref(
args.export_dref, dref, precision=args.dref_precision
)