Commit b3143f5a authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Enhance metrics output

parent 0f3884b0
Pipeline #24716 failed with stages
in 244 minutes and 39 seconds
......@@ -108,12 +108,12 @@ class MetricChange(Enum):
}
return strings[self]
def short_name(self):
def hint(self):
strings = {
MetricChange.NewMetric: "new",
MetricChange.NoChange: "unch",
MetricChange.Increase: "incr",
MetricChange.Decrease: "decr"
MetricChange.NewMetric: colored(Color.BLUE,"NEW"),
MetricChange.NoChange: "",
MetricChange.Increase: colored(Color.RED, "BAD"),
MetricChange.Decrease: colored(Color.GREEN,"GOOD")
}
return strings[self]
......
......@@ -348,21 +348,21 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
hideBaselineEnv = not hasBaseline or all(
[x.stat.test_env == x.baseline.perfStat.test_env
for x in metrics if x.baseline is not None])
def row(cells: Tuple[str, str, str, str, str, str, str]) -> List[str]:
def row(cells: Tuple[str, str, str, str, str, str, str, str]) -> List[str]:
return [x for (idx, x) in enumerate(list(cells)) if
(idx != 2 or not hideBaselineCommit) and
(idx != 3 or not hideBaselineEnv )]
headerRows = [
row(("", "", "Baseline", "Baseline", "Baseline", "", "")),
row(("Test", "Metric", "commit", "environment", "value", "New value", "Change"))
row(("", "", "Baseline", "Baseline", "Baseline", "", "", "")),
row(("Test", "Metric", "commit", "environment", "value", "New value", "Change", ""))
]
def strDiff(x: PerfMetric) -> str:
if x.baseline is None:
return ""
val0 = x.baseline.perfStat.value
val1 = x.stat.value
return "{}({:+2.1f}%)".format(x.change.short_name(), 100 * (val1 - val0) / val0)
return "{:+2.1f}%".format(100 * (val1 - val0) / val0)
dataRows = [row((
"{}({})".format(x.stat.test, x.stat.way),
shorten_metric_name(x.stat.metric),
......@@ -374,7 +374,8 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
"{:13.1f}".format(x.baseline.perfStat.value)
if x.baseline is not None else "",
"{:13.1f}".format(x.stat.value),
strDiff(x)
strDiff(x),
"{}".format(x.change.hint())
)) for x in sorted(metrics, key =
lambda m: (m.stat.test, m.stat.way, m.stat.metric))]
print_table(headerRows, dataRows, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment