Skip to content

Commit

Permalink
fix up diff to only operate when compilation goes over a second
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Dec 6, 2024
1 parent 07ef769 commit 6ad171c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/compilation_report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const computeCompilationDiff = (
if (refReports.length === compilationReports.length) {
for (let i = 0; i < refReports.length; i++) {
let diff_str = "N/A";
let minSeconds = 0;
if (refReports[i].artifact_name === compilationReports[i].artifact_name) {
const compTimeString = compilationReports[i].time;
const refTimeString = refReports[i].time;
Expand All @@ -49,27 +50,35 @@ export const computeCompilationDiff = (
refSecondsString.substring(0, refSecondsString.length - 1)
);
const refSeconds = refMinutesValue * 60 + refSecondsValue;
minSeconds = Math.min(refSeconds, compSeconds);

const diff = Math.floor(((compSeconds - refSeconds) / refSeconds) * 100);
if (diff != 0 && refSeconds > 1 && compSeconds > 1) {
if (diff != 0) {
diff_column = true;
}
diff_str = diff.toString() + "%";
}
diff_percentage.push(diff_str);

// Reports under one seconds can often vary in their diff percentage by quite a bit more (e.g. .2 ms to .25 ms),
// which can make it more difficult to interpret the output
if (minSeconds > 1) {
diff_percentage.push({ report_index: i, diff_str: diff_str });
}
}
}
console.log("diff_column: ", diff_column);

if (diff_column == true) {
markdown = "## Compilation Sample\n | Program | Compilation Time | % |\n | --- | --- | --- |\n";
for (let i = 0; i < compilationReports.length; i++) {
for (let i = 0; i < diff_percentage.length; i++) {
const diffRow = diff_percentage[i];
const reportIndex = diffRow.report_index;
markdown = markdown.concat(
" | ",
compilationReports[i].artifact_name,
compilationReports[reportIndex].artifact_name,
" | ",
compilationReports[i].time,
compilationReports[reportIndex].time,
" | ",
diff_percentage[i],
diffRow.diff_str,
" |\n"
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Compilation Sample
| Program | Compilation Time | % |
| --- | --- | --- |
| keccak256 | 0m0.325s | 16% |
| workspace | 0m0.300s | 10% |
| regression_4709 | 0m1.842s | 2% |
| ram_blowup_regression | 0m20.526s | -1% |

0 comments on commit 6ad171c

Please sign in to comment.