diff --git a/scripts/report.mjs b/scripts/report.mjs index 44bc0a8..5d69eb5 100644 --- a/scripts/report.mjs +++ b/scripts/report.mjs @@ -10,6 +10,11 @@ export function sha256(value) { return createHash('sha256').update(value).digest('hex'); } +export function hashFilesSingle(value) { + const contentHash = createHash('sha256').update(value).digest(); + return createHash('sha256').update(contentHash).digest('hex'); +} + export function secondsBetween(start, end) { if (!start || !end) return null; return (Date.parse(end) - Date.parse(start)) / 1000; @@ -91,6 +96,7 @@ function summarize(rows, caches) { const versionCaches = caches.filter(cache => cache.version === version); const caseTotals = new Map(); for (const cache of versionCaches) { + if (cache.sizeBytes === null) continue; const key = `${cache.distribution}-${cache.iteration}`; caseTotals.set(key, (caseTotals.get(key) ?? 0) + cache.sizeBytes); } @@ -220,11 +226,13 @@ export async function main(env = process.env) { const expected = [ { type: 'maven-dependencies', - key: `setup-java-Linux-x64-maven-${sha256(`${benchmarkId}\n`)}` + key: `setup-java-Linux-x64-maven-${hashFilesSingle( + `${benchmarkId}\n` + )}` }, { type: 'maven-wrapper', - key: `setup-java-Linux-x64-maven-wrapper-${sha256( + key: `setup-java-Linux-x64-maven-wrapper-${hashFilesSingle( `${wrapperOriginal}# benchmark-id=${benchmarkId}\n` )}` } diff --git a/scripts/report.test.mjs b/scripts/report.test.mjs index 65cbdbe..e3381ab 100644 --- a/scripts/report.test.mjs +++ b/scripts/report.test.mjs @@ -2,6 +2,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import { + hashFilesSingle, median, parseBenchmarkJob, secondsBetween, @@ -13,6 +14,10 @@ test('hashes benchmark cache markers', () => { sha256('benchmark\n'), '8f8dbecfd77ab2386b49d723c6b2474f2c22c246805fa0f677bbaf6e4f7bbbfe' ); + assert.equal( + hashFilesSingle('main-microsoft-1-30462682067\n'), + 'f0c1009aeb8d8582a73a81f3b0146467ed727211971e4052fccd9b7d60817d8f' + ); }); test('calculates medians', () => {