Add the rebuilt modules to the benchmark formatting
Test: format_benchmarks
Change-Id: Ib3fffc99a1c66a2f700c27821886e8de2e2ec041
diff --git a/tools/perf/format_benchmarks b/tools/perf/format_benchmarks
index 845d73f..162c577 100755
--- a/tools/perf/format_benchmarks
+++ b/tools/perf/format_benchmarks
@@ -86,10 +86,12 @@
class Table:
- def __init__(self):
+ def __init__(self, row_title, fixed_titles=[]):
self._data = {}
self._rows = []
self._cols = []
+ self._fixed_cols = {}
+ self._titles = [row_title] + fixed_titles
def Set(self, column_key, row_key, data):
self._data[(column_key, row_key)] = data
@@ -98,19 +100,27 @@
if not row_key in self._rows:
self._rows.append(row_key)
+ def SetFixedCol(self, row_key, columns):
+ self._fixed_cols[row_key] = columns
+
def Write(self, out):
table = []
# Expand the column items
for row in zip(*self._cols):
if row.count(row[0]) == len(row):
continue
- table.append([""] + [col for col in row])
+ table.append([""] * len(self._titles) + [col for col in row])
if table:
+ # Update the last row of the header with title and add separator
+ for i in range(len(self._titles)):
+ table[len(table)-1][i] = self._titles[i]
table.append(pretty.SEPARATOR)
# Populate the data
for row in self._rows:
- table.append([str(row)] + [str(self._data.get((col, row), "")) for col in self._cols])
- out.write(pretty.FormatTable(table))
+ table.append([str(row)]
+ + self._fixed_cols[row]
+ + [str(self._data.get((col, row), "")) for col in self._cols])
+ out.write(pretty.FormatTable(table, alignments="LL"))
def format_duration_sec(ns):
@@ -173,11 +183,12 @@
in group_by(summary["benchmarks"], bm_key)]
# Build the table
- table = Table()
+ table = Table("Benchmark", ["Rebuild"])
for filename, summary in summaries:
for key, column in summary["columns"]:
for id, cell in column:
duration_ns = statistics.median([b["duration_ns"] for b in cell])
+ table.SetFixedCol(cell[0]["title"], [" ".join(cell[0]["modules"])])
table.Set(tuple([summary["date"].strftime("%Y-%m-%d"),
summary["branch"],
summary["tag"]]