Skip to content

Commit

Permalink
Always add size summary report to sketches report
Browse files Browse the repository at this point in the history
In addition to per-sketch, per-board memory usage data, the sketches report contains a per-board summary of the results
from all the compilations for that board.

Previously, when deltas data was not available, this summary section was arbitrarily omitted entirely from the sketches
report. However, there is still board-universal information even without deltas:

- Memory types
- Maximums for each memory type

It is useful to have that information available on a per-board level so a summary report should always be added to the
sketches report.
  • Loading branch information
per1234 committed Mar 31, 2023
1 parent e96af16 commit f7b700d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 84 deletions.
130 changes: 47 additions & 83 deletions compilesketches/compilesketches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,55 +1300,52 @@ def get_sizes_summary_report(self, sketch_report_list):
sizes_summary_report = []
for sketch_report in sketch_report_list:
for size_report in sketch_report[self.ReportKeys.sizes]:
if self.ReportKeys.delta in size_report:
# Determine the sizes_summary_report index for this memory type
size_summary_report_index_list = [
index
for index, size_summary in enumerate(sizes_summary_report)
if size_summary.get(self.ReportKeys.name) == size_report[self.ReportKeys.name]
]
if not size_summary_report_index_list:
# There is no existing entry in the summary list for this memory type, so create one
sizes_summary_report.append(
{
self.ReportKeys.name: size_report[self.ReportKeys.name],
self.ReportKeys.maximum: size_report[self.ReportKeys.maximum],
self.ReportKeys.delta: {
self.ReportKeys.absolute: {
self.ReportKeys.minimum: size_report[self.ReportKeys.delta][
self.ReportKeys.absolute
],
self.ReportKeys.maximum: size_report[self.ReportKeys.delta][
self.ReportKeys.absolute
],
},
self.ReportKeys.relative: {
self.ReportKeys.minimum: size_report[self.ReportKeys.delta][
self.ReportKeys.relative
],
self.ReportKeys.maximum: size_report[self.ReportKeys.delta][
self.ReportKeys.relative
],
},
},
}
)
else:
size_summary_report_index = size_summary_report_index_list[0]
# Determine the sizes_summary_report index for this memory type
size_summary_report_index_list = [
index
for index, size_summary in enumerate(sizes_summary_report)
if size_summary.get(self.ReportKeys.name) == size_report[self.ReportKeys.name]
]
if not size_summary_report_index_list:
# There is no existing entry in the summary list for this memory type, so create one
sizes_summary_report.append({self.ReportKeys.name: size_report[self.ReportKeys.name]})
size_summary_report_index = len(sizes_summary_report) - 1
else:
size_summary_report_index = size_summary_report_index_list[0]

if (
sizes_summary_report[size_summary_report_index][self.ReportKeys.maximum]
== self.not_applicable_indicator
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.maximum] = size_report[
self.ReportKeys.maximum
]
if (
self.ReportKeys.maximum not in sizes_summary_report[size_summary_report_index]
or sizes_summary_report[size_summary_report_index][self.ReportKeys.maximum]
== self.not_applicable_indicator
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.maximum] = size_report[
self.ReportKeys.maximum
]

if self.ReportKeys.delta in size_report:
if (
self.ReportKeys.delta not in sizes_summary_report[size_summary_report_index]
or sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.minimum]
== self.not_applicable_indicator
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta] = {
self.ReportKeys.absolute: {
self.ReportKeys.minimum: size_report[self.ReportKeys.delta][self.ReportKeys.absolute],
self.ReportKeys.maximum: size_report[self.ReportKeys.delta][self.ReportKeys.absolute],
},
self.ReportKeys.relative: {
self.ReportKeys.minimum: size_report[self.ReportKeys.delta][self.ReportKeys.relative],
self.ReportKeys.maximum: size_report[self.ReportKeys.delta][self.ReportKeys.relative],
},
}
elif size_report[self.ReportKeys.delta][self.ReportKeys.absolute] != self.not_applicable_indicator:
if (
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
size_report[self.ReportKeys.delta][self.ReportKeys.absolute]
< sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.minimum]
== self.not_applicable_indicator
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
Expand All @@ -1358,6 +1355,12 @@ def get_sizes_summary_report(self, sketch_report_list):
self.ReportKeys.relative
][self.ReportKeys.minimum] = size_report[self.ReportKeys.delta][self.ReportKeys.relative]

if (
size_report[self.ReportKeys.delta][self.ReportKeys.absolute]
> sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.maximum]
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.maximum] = size_report[self.ReportKeys.delta][self.ReportKeys.absolute]
Expand All @@ -1366,45 +1369,6 @@ def get_sizes_summary_report(self, sketch_report_list):
self.ReportKeys.relative
][self.ReportKeys.maximum] = size_report[self.ReportKeys.delta][self.ReportKeys.relative]

elif size_report[self.ReportKeys.delta][self.ReportKeys.absolute] != (
self.not_applicable_indicator
):
if (
size_report[self.ReportKeys.delta][self.ReportKeys.absolute]
< sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.minimum]
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.minimum] = size_report[self.ReportKeys.delta][
self.ReportKeys.absolute
]

sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.relative
][self.ReportKeys.minimum] = size_report[self.ReportKeys.delta][
self.ReportKeys.relative
]

if (
size_report[self.ReportKeys.delta][self.ReportKeys.absolute]
> sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.maximum]
):
sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.absolute
][self.ReportKeys.maximum] = size_report[self.ReportKeys.delta][
self.ReportKeys.absolute
]

sizes_summary_report[size_summary_report_index][self.ReportKeys.delta][
self.ReportKeys.relative
][self.ReportKeys.maximum] = size_report[self.ReportKeys.delta][
self.ReportKeys.relative
]

return sizes_summary_report

def get_warnings_summary_report(self, sketch_report_list):
Expand Down
11 changes: 10 additions & 1 deletion compilesketches/tests/test_compilesketches.py
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,16 @@ def test_get_sizes_summary_report():
},
]

expected_sizes_summary_report = []
expected_sizes_summary_report = [
{
compilesketches.CompileSketches.ReportKeys.name: "Foo memory type",
compilesketches.CompileSketches.ReportKeys.maximum: 111,
},
{
compilesketches.CompileSketches.ReportKeys.name: "Bar memory type",
compilesketches.CompileSketches.ReportKeys.maximum: 222,
},
]

assert compile_sketches.get_sizes_summary_report(sketch_report_list=sketch_report_list) == (
expected_sizes_summary_report
Expand Down

0 comments on commit f7b700d

Please sign in to comment.