From 2211601fa35b26d411bd1a4f151e147da6123362 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 31 Jul 2025 16:13:32 +0200 Subject: [PATCH 1/5] add validation --- generators/async-file-system.js | 25 +++++++++++++++++++++++-- generators/sync-file-system.js | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/generators/async-file-system.js b/generators/async-file-system.js index fac354b2..44c061f2 100644 --- a/generators/async-file-system.js +++ b/generators/async-file-system.js @@ -56,9 +56,13 @@ class File { set data(dataView) { this._data = dataView; } swapByteOrder() { + let hash = 0x1a2b3c4d; for (let i = 0; i < Math.floor(this.data.byteLength / 8) * 8; i += 8) { - this.data.setFloat64(i, this.data.getFloat64(i, isLittleEndian), !isLittleEndian); + const data = this.data.getFloat64(i, isLittleEndian); + this.data.setFloat64(i, data, !isLittleEndian); + hash ^= data | 0; } + return hash; } } @@ -171,11 +175,17 @@ async function setupDirectory() { } class Benchmark { + EXPECTED_FILE_COUNT = 666; + EXPECTED_LAST_FILE_HASH = 1024076396; + + totalFileCount = 0; + lastFileHash = 0; + async runIteration() { const fs = await setupDirectory(); for await (let { entry: file } of fs.forEachFileRecursively()) { - file.swapByteOrder(); + this.lastFileHash = file.swapByteOrder(); } for await (let { name, entry: dir } of fs.forEachDirectoryRecursively()) { @@ -187,5 +197,16 @@ class Benchmark { } } } + + for await (let _ of fs.forEachFileRecursively()) { + this.totalFileCount++; + } + } + + validate(iterations) { + if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) + throw new Error(`Invalid total file count ${this.totalFileCount}`); + if (this.lastFileHash != this.EXPECTED_LAST_FILE_HASH) + throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } diff --git a/generators/sync-file-system.js b/generators/sync-file-system.js index 3b33d91a..f9f8791a 100644 --- a/generators/sync-file-system.js +++ b/generators/sync-file-system.js @@ -53,9 +53,13 @@ class File { set data(dataView) { this._data = dataView; } swapByteOrder() { + let hash = 0x1a2b3c4d; for (let i = 0; i < Math.floor(this.data.byteLength / 8) * 8; i += 8) { - this.data.setFloat64(i, this.data.getFloat64(i, isLittleEndian), !isLittleEndian); + const data = this.data.getFloat64(i, isLittleEndian); + this.data.setFloat64(i, data, !isLittleEndian); + hash ^= data | 0; } + return hash; } } @@ -161,11 +165,17 @@ function setupDirectory() { } class Benchmark { + EXPECTED_FILE_COUNT = 411; + EXPECTED_LAST_FILE_HASH = 1042364057; + + totalFileCount = 0; + lastFileHash = 0; + runIteration() { const fs = setupDirectory(); for (let { entry: file } of fs.forEachFileRecursively()) { - file.swapByteOrder(); + this.lastFileHash = file.swapByteOrder(); } for (let { name, entry: dir } of fs.forEachDirectoryRecursively()) { @@ -178,5 +188,16 @@ class Benchmark { } } } + + for (let _ of fs.forEachFileRecursively()) { + this.totalFileCount++; + } + } + + validate(iterations) { + if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) + throw new Error(`Invalid total file count ${this.totalFileCount}`); + if (this.lastFileHash != this.EXPECTED_LAST_FILE_HASH) + throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } From edeb9014d2d0a2d4659dda2dde7494a338b9b0dc Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 31 Jul 2025 17:01:38 +0200 Subject: [PATCH 2/5] fix file hash --- JetStreamDriver.js | 3 ++- generators/async-file-system.js | 5 ++--- generators/sync-file-system.js | 5 ++--- tests/run.mjs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index de06496d..3fdb8d26 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -2391,7 +2391,8 @@ function processTestList(testList) else benchmarkNames = testList.split(/[\s,]/); - for (const name of benchmarkNames) { + for (let name of benchmarkNames) { + name = name.toLowerCase(); if (benchmarksByTag.has(name)) benchmarks.push(...findBenchmarksByTag(name)); else diff --git a/generators/async-file-system.js b/generators/async-file-system.js index 44c061f2..c026a0d0 100644 --- a/generators/async-file-system.js +++ b/generators/async-file-system.js @@ -176,10 +176,9 @@ async function setupDirectory() { class Benchmark { EXPECTED_FILE_COUNT = 666; - EXPECTED_LAST_FILE_HASH = 1024076396; totalFileCount = 0; - lastFileHash = 0; + lastFileHash = undefined; async runIteration() { const fs = await setupDirectory(); @@ -206,7 +205,7 @@ class Benchmark { validate(iterations) { if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) throw new Error(`Invalid total file count ${this.totalFileCount}`); - if (this.lastFileHash != this.EXPECTED_LAST_FILE_HASH) + if (this.lastFileHash !== undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } diff --git a/generators/sync-file-system.js b/generators/sync-file-system.js index f9f8791a..12e6de3f 100644 --- a/generators/sync-file-system.js +++ b/generators/sync-file-system.js @@ -166,10 +166,9 @@ function setupDirectory() { class Benchmark { EXPECTED_FILE_COUNT = 411; - EXPECTED_LAST_FILE_HASH = 1042364057; totalFileCount = 0; - lastFileHash = 0; + lastFileHash = undefined; runIteration() { const fs = setupDirectory(); @@ -197,7 +196,7 @@ class Benchmark { validate(iterations) { if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) throw new Error(`Invalid total file count ${this.totalFileCount}`); - if (this.lastFileHash != this.EXPECTED_LAST_FILE_HASH) + if (this.lastFileHash !== undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } diff --git a/tests/run.mjs b/tests/run.mjs index 6ef609a9..e3fee908 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -118,7 +118,7 @@ async function benchmarkResults(driver) { class JetStreamTestError extends Error { constructor(errors) { - super(`Tests failed: ${errors.map(e => e.name).join(", ")}`); + super(`Tests failed: ${errors.map(e => e.stack).join(", ")}`); this.errors = errors; } From 21fb2bc5642b3c30bf75828fcb086b149c207c5d Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 31 Jul 2025 17:04:52 +0200 Subject: [PATCH 3/5] bump script timeout --- tests/run.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.mjs b/tests/run.mjs index e3fee908..67f0f11f 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -103,7 +103,7 @@ async function testEnd2End(params) { async function benchmarkResults(driver) { logInfo("JetStream START"); - await driver.manage().setTimeouts({ script: 60_000 }); + await driver.manage().setTimeouts({ script: 2 * 60_000 }); await driver.executeAsyncScript((callback) => { globalThis.JetStream.start(); callback(); From 6046637b317f74448e8f1a4282dcb536299f4f98 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 31 Jul 2025 17:12:34 +0200 Subject: [PATCH 4/5] fix test (need glasses) --- generators/async-file-system.js | 2 +- generators/sync-file-system.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/async-file-system.js b/generators/async-file-system.js index c026a0d0..81a7bc12 100644 --- a/generators/async-file-system.js +++ b/generators/async-file-system.js @@ -205,7 +205,7 @@ class Benchmark { validate(iterations) { if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) throw new Error(`Invalid total file count ${this.totalFileCount}`); - if (this.lastFileHash !== undefined) + if (this.lastFileHash === undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } diff --git a/generators/sync-file-system.js b/generators/sync-file-system.js index 12e6de3f..d11d4d50 100644 --- a/generators/sync-file-system.js +++ b/generators/sync-file-system.js @@ -196,7 +196,7 @@ class Benchmark { validate(iterations) { if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) throw new Error(`Invalid total file count ${this.totalFileCount}`); - if (this.lastFileHash !== undefined) + if (this.lastFileHash === undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); } } From 57e3f8d3116726432fa715beff7eb967b1080b49 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 4 Aug 2025 18:26:09 +0200 Subject: [PATCH 5/5] address comments --- JetStreamDriver.js | 2 +- generators/async-file-system.js | 5 +++-- generators/sync-file-system.js | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 3fdb8d26..f1e0f37a 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -2394,7 +2394,7 @@ function processTestList(testList) for (let name of benchmarkNames) { name = name.toLowerCase(); if (benchmarksByTag.has(name)) - benchmarks.push(...findBenchmarksByTag(name)); + benchmarks.concat(findBenchmarksByTag(name)); else benchmarks.push(findBenchmarkByName(name)); } diff --git a/generators/async-file-system.js b/generators/async-file-system.js index 81a7bc12..9f85daf0 100644 --- a/generators/async-file-system.js +++ b/generators/async-file-system.js @@ -203,8 +203,9 @@ class Benchmark { } validate(iterations) { - if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) - throw new Error(`Invalid total file count ${this.totalFileCount}`); + const expectedFileCount = this.EXPECTED_FILE_COUNT * iterations; + if (this.totalFileCount != expectedFileCount) + throw new Error(`Invalid total file count ${this.totalFileCount}, expected ${expectedFileCount}.`); if (this.lastFileHash === undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); } diff --git a/generators/sync-file-system.js b/generators/sync-file-system.js index d11d4d50..60fbdeff 100644 --- a/generators/sync-file-system.js +++ b/generators/sync-file-system.js @@ -194,8 +194,9 @@ class Benchmark { } validate(iterations) { - if (this.totalFileCount != this.EXPECTED_FILE_COUNT * iterations) - throw new Error(`Invalid total file count ${this.totalFileCount}`); + const expectedFileCount = this.EXPECTED_FILE_COUNT * iterations; + if (this.totalFileCount != expectedFileCount) + throw new Error(`Invalid total file count ${this.totalFileCount}, expected ${expectedFileCount}.`); if (this.lastFileHash === undefined) throw new Error(`Invalid file hash: ${this.lastFileHash}`); }