summaryrefslogtreecommitdiff
path: root/bin/analyze-archive.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/analyze-archive.py')
-rwxr-xr-xbin/analyze-archive.py147
1 files changed, 3 insertions, 144 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py
index 723ea9b..d939c44 100755
--- a/bin/analyze-archive.py
+++ b/bin/analyze-archive.py
@@ -106,133 +106,6 @@ def model_summary_table(result_list):
print(buf)
-def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq):
- state_attributes = model.attributes(model.states[0])
- trans_attributes = model.attributes(model.transitions[0])
-
- print("# Setup")
- print("* Input files: `", " ".join(raw_data.filenames), "`")
- print(
- f"""* Number of usable / performed measurements: {raw_data.preprocessing_stats["num_valid"]}/{raw_data.preprocessing_stats["num_runs"]}"""
- )
- print(f"""* State duration: {raw_data.setup_by_fileno[0]["state_duration"]} ms""")
- print()
- print("# States")
-
- for state in model.states:
- print()
- print(f"## {state}")
- print()
- for param in model.parameters:
- print(
- "* {} ∈ {}".format(
- param,
- model.attr_by_name[state][
- "power"
- ].stats.distinct_values_by_param_name[param],
- )
- )
- for attribute in state_attributes:
- unit = ""
- if attribute == "power":
- unit = "µW"
- static_quality = pq[state][attribute]["smape"]
- print(
- f"* {attribute} mean: {pm(state, attribute):.0f} {unit} (± {static_quality:.1f}%)"
- )
- if ai(state, attribute):
- analytic_quality = aq[state][attribute]["smape"]
- fstr = ai(state, attribute)["function"].model_function
- fstr = fstr.replace("0 + ", "", 1)
- for i, marg in enumerate(ai(state, attribute)["function"].model_args):
- fstr = fstr.replace(f"regression_arg({i})", str(marg))
- fstr = fstr.replace("+ -", "-")
- print(f"* {attribute} function: {fstr} (± {analytic_quality:.1f}%)")
-
- print()
- print("# Transitions")
-
- for trans in model.transitions:
- print()
- print(f"## {trans}")
- print()
- for param in model.parameters:
- print(
- "* {} ∈ {}".format(
- param,
- model.attr_by_name[trans][
- "duration"
- ].stats.distinct_values_by_param_name[param],
- )
- )
- for attribute in trans_attributes:
- unit = ""
- if attribute == "duration":
- unit = "µs"
- elif attribute in ["energy", "rel_energy_prev"]:
- unit = "pJ"
- static_quality = pq[trans][attribute]["smape"]
- print(
- f"* {attribute} mean: {pm(trans, attribute):.0f} {unit} (± {static_quality:.1f}%)"
- )
- if ai(trans, attribute):
- analytic_quality = aq[trans][attribute]["smape"]
- fstr = ai(trans, attribute)["function"].model_function
- fstr = fstr.replace("0 + ", "", 1)
- for i, marg in enumerate(ai(trans, attribute)["function"].model_args):
- fstr = fstr.replace(f"regression_arg({i})", str(marg))
- fstr = fstr.replace("+ -", "-")
- print(f"* {attribute} function: {fstr} (± {analytic_quality:.1f}%)")
-
- print(
- "<table><tr><th>state</th><th>"
- + "</th><th>".join(state_attributes)
- + "</th></tr>"
- )
- for state in model.states:
- print("<tr>", end="")
- print("<td>{}</td>".format(state), end="")
- for attribute in state_attributes:
- unit = ""
- if attribute == "power":
- unit = "µW"
- print(
- "<td>{:.0f} {} ({:.1f}%)</td>".format(
- pm(state, attribute), unit, pq[state][attribute]["smape"]
- ),
- end="",
- )
- print("</tr>")
- print("</table>")
-
- trans_attributes = model.attributes(model.transitions[0])
- if "rel_energy_prev" in trans_attributes:
- trans_attributes.remove("rel_energy_next")
-
- print(
- "<table><tr><th>transition</th><th>"
- + "</th><th>".join(trans_attributes)
- + "</th></tr>"
- )
- for trans in model.transitions:
- print("<tr>", end="")
- print("<td>{}</td>".format(trans), end="")
- for attribute in trans_attributes:
- unit = ""
- if attribute == "duration":
- unit = "µs"
- elif attribute in ["energy", "rel_energy_prev"]:
- unit = "pJ"
- print(
- "<td>{:.0f} {} ({:.1f}%)</td>".format(
- pm(trans, attribute), unit, pq[trans][attribute]["smape"]
- ),
- end="",
- )
- print("</tr>")
- print("</table>")
-
-
def get_kconfig(model):
buf = str()
for param_name in model.parameters:
@@ -351,18 +224,17 @@ if __name__ == "__main__":
)
parser.add_argument(
"--show-models",
- choices=["static", "paramdetection", "param", "all", "html"],
+ choices=["static", "paramdetection", "param", "all"],
action="append",
default=list(),
help="static: show static model values as well as parameter detection heuristic.\n"
"paramdetection: show stddev of static/lut/fitted model\n"
"param: show parameterized model functions and regression variable values\n"
- "all: all of the above\n"
- "html: print model and quality data as HTML table on stdout",
+ "all: all of the above",
)
parser.add_argument(
"--show-quality",
- choices=["table", "summary", "all", "tex", "html"],
+ choices=["table", "summary", "all", "tex"],
action="append",
default=list(),
help="table: show static/fitted/lut SMAPE and MAE for each name and attribute.\n"
@@ -898,19 +770,6 @@ if __name__ == "__main__":
analytic_quality = model.assess(param_model)
xv_analytic_models = None
- if "html" in show_models or "html" in show_quality:
- print_html_model_data(
- raw_data,
- model,
- static_model,
- static_quality,
- lut_model,
- lut_quality,
- param_model,
- param_info,
- analytic_quality,
- )
-
if "table" in show_quality or "all" in show_quality:
dfatool.cli.model_quality_table(
["static", "parameterized", "LUT"],