change output for metrics compare by pr

This commit is contained in:
jpaul 2023-11-14 16:45:01 +01:00
parent b035e809a3
commit 0598cd6a2c
3 changed files with 159 additions and 0 deletions

51
dist/cleanup/index.js generated vendored
View File

@ -74462,6 +74462,7 @@ function generateReports() {
}
if (arePRReportsEnabled()) {
(0, utils_1.createPRComment)(report);
const prBaseReport = createPRComparison(buildOutput, prMetrics);
(0, utils_1.createPRComment)(prBaseReport);
}
}
@ -74491,6 +74492,56 @@ function setNativeImageOption(value) {
fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`);
}
}
function createPRComparison(dataRecent, dataBase) {
const detailsRecent = dataRecent.image_details;
const detailsBase = dataBase.image_details;
const debugInfoBytesRecent = detailsRecent.debug_info ? detailsRecent.debug_info.bytes : 0;
const otherBytesRecent = detailsRecent.total_bytes -
detailsRecent.code_area.bytes -
detailsRecent.image_heap.bytes -
debugInfoBytesRecent;
const debugInfoBytesBase = detailsBase.debug_info ? detailsBase.debug_info.bytes : 0;
const otherBytesBase = detailsBase.total_bytes -
detailsBase.code_area.bytes -
detailsBase.image_heap.bytes -
debugInfoBytesBase;
return `## GraalVM Native Image PR comparison
#### Image Details
<table>
<thead>
<tr>
<th align="left">Category</th>
<th align="right">Recent Branch</th>
<th align="right">Base Branch</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-code-area" target="_blank">Code area</a></td>
<td align="right">${bytesToHuman(detailsRecent.code_area.bytes)} (${toPercent(detailsRecent.code_area.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.code_area.bytes)} (${toPercent(detailsBase.code_area.bytes, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-image-heap" target="_blank">Image heap</a></td>
<td align="right">${bytesToHuman(detailsRecent.image_heap.bytes)} (${toPercent(detailsRecent.image_heap.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.image_heap.bytes)} (${toPercent(detailsBase.image_heap.bytes, detailsBase.total_bytes)}%)</td>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
<td align="right">${bytesToHuman(otherBytesRecent)} (${toPercent(otherBytesRecent, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(otherBytesBase)} (${toPercent(otherBytesBase, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left">Total</td>
<td align="right"><strong>${bytesToHuman(detailsRecent.total_bytes)} (100.000%)</td>
<td align="right"><strong>${bytesToHuman(detailsBase.total_bytes)} (100.000%)</td>
</tr>
</tbody>
</table>
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`;
}
function createReport(data) {
const context = github.context;
const info = data.general_info;

51
dist/main/index.js generated vendored
View File

@ -74561,6 +74561,7 @@ function generateReports() {
}
if (arePRReportsEnabled()) {
(0, utils_1.createPRComment)(report);
const prBaseReport = createPRComparison(buildOutput, prMetrics);
(0, utils_1.createPRComment)(prBaseReport);
}
}
@ -74590,6 +74591,56 @@ function setNativeImageOption(value) {
fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`);
}
}
function createPRComparison(dataRecent, dataBase) {
const detailsRecent = dataRecent.image_details;
const detailsBase = dataBase.image_details;
const debugInfoBytesRecent = detailsRecent.debug_info ? detailsRecent.debug_info.bytes : 0;
const otherBytesRecent = detailsRecent.total_bytes -
detailsRecent.code_area.bytes -
detailsRecent.image_heap.bytes -
debugInfoBytesRecent;
const debugInfoBytesBase = detailsBase.debug_info ? detailsBase.debug_info.bytes : 0;
const otherBytesBase = detailsBase.total_bytes -
detailsBase.code_area.bytes -
detailsBase.image_heap.bytes -
debugInfoBytesBase;
return `## GraalVM Native Image PR comparison
#### Image Details
<table>
<thead>
<tr>
<th align="left">Category</th>
<th align="right">Recent Branch</th>
<th align="right">Base Branch</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-code-area" target="_blank">Code area</a></td>
<td align="right">${bytesToHuman(detailsRecent.code_area.bytes)} (${toPercent(detailsRecent.code_area.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.code_area.bytes)} (${toPercent(detailsBase.code_area.bytes, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-image-heap" target="_blank">Image heap</a></td>
<td align="right">${bytesToHuman(detailsRecent.image_heap.bytes)} (${toPercent(detailsRecent.image_heap.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.image_heap.bytes)} (${toPercent(detailsBase.image_heap.bytes, detailsBase.total_bytes)}%)</td>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
<td align="right">${bytesToHuman(otherBytesRecent)} (${toPercent(otherBytesRecent, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(otherBytesBase)} (${toPercent(otherBytesBase, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left">Total</td>
<td align="right"><strong>${bytesToHuman(detailsRecent.total_bytes)} (100.000%)</td>
<td align="right"><strong>${bytesToHuman(detailsBase.total_bytes)} (100.000%)</td>
</tr>
</tbody>
</table>
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`;
}
function createReport(data) {
const context = github.context;
const info = data.general_info;

View File

@ -148,6 +148,7 @@ export async function generateReports(): Promise<void> {
}
if (arePRReportsEnabled()) {
createPRComment(report)
const prBaseReport = createPRComparison(buildOutput, prMetrics)
createPRComment(prBaseReport)
}
}
@ -179,6 +180,61 @@ function setNativeImageOption(value: string): void {
}
}
function createPRComparison(dataRecent: BuildOutput, dataBase: BuildOutput): string {
const detailsRecent = dataRecent.image_details
const detailsBase = dataBase.image_details
const debugInfoBytesRecent = detailsRecent.debug_info ? detailsRecent.debug_info.bytes : 0
const otherBytesRecent =
detailsRecent.total_bytes -
detailsRecent.code_area.bytes -
detailsRecent.image_heap.bytes -
debugInfoBytesRecent
const debugInfoBytesBase = detailsBase.debug_info ? detailsBase.debug_info.bytes : 0
const otherBytesBase =
detailsBase.total_bytes -
detailsBase.code_area.bytes -
detailsBase.image_heap.bytes -
debugInfoBytesBase
return `## GraalVM Native Image PR comparison
#### Image Details
<table>
<thead>
<tr>
<th align="left">Category</th>
<th align="right">Recent Branch</th>
<th align="right">Base Branch</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-code-area" target="_blank">Code area</a></td>
<td align="right">${bytesToHuman(detailsRecent.code_area.bytes)} (${toPercent(detailsRecent.code_area.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.code_area.bytes)} (${toPercent(detailsBase.code_area.bytes, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-image-heap" target="_blank">Image heap</a></td>
<td align="right">${bytesToHuman(detailsRecent.image_heap.bytes)} (${toPercent(detailsRecent.image_heap.bytes, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(detailsBase.image_heap.bytes)} (${toPercent(detailsBase.image_heap.bytes, detailsBase.total_bytes)}%)</td>
<tr>
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
<td align="right">${bytesToHuman(otherBytesRecent)} (${toPercent(otherBytesRecent, detailsRecent.total_bytes)}%)</td>
<td align="right">${bytesToHuman(otherBytesBase)} (${toPercent(otherBytesBase, detailsBase.total_bytes)}%)</td>
</tr>
<tr>
<td align="left">Total</td>
<td align="right"><strong>${bytesToHuman(detailsRecent.total_bytes)} (100.000%)</td>
<td align="right"><strong>${bytesToHuman(detailsBase.total_bytes)} (100.000%)</td>
</tr>
</tbody>
</table>
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`
}
function createReport(data: BuildOutput): string {
const context = github.context
const info = data.general_info
@ -438,6 +494,7 @@ function createReport(data: BuildOutput): string {
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`
}
function toPercent(part: number, total: number): string {
return `${((part / total) * 100).toFixed(3)}%`
}