From 25cf978ef66408f79de82eeabe5e70186105b095 Mon Sep 17 00:00:00 2001 From: Keith Miller Date: Thu, 19 Dec 2024 10:20:02 -0500 Subject: [PATCH] Move argon2 to first, average, worst scoring. Since the non-simd version of the test is relatively slow I reduced the iteration/worst counts to 15/2, repsectively. Also, I moved all the benchmark files to the argon2 directory to help organize the wasm directory a bit. --- JetStreamDriver.js | 22 ++++++------ wasm/{ => argon2}/argon2-bundle.js | 0 wasm/{ => argon2}/argon2-simd.wasm | Bin wasm/{ => argon2}/argon2.js | 0 wasm/{ => argon2}/argon2.wasm | Bin .../benchmark.js} | 32 ++++++++---------- 6 files changed, 27 insertions(+), 27 deletions(-) rename wasm/{ => argon2}/argon2-bundle.js (100%) rename wasm/{ => argon2}/argon2-simd.wasm (100%) rename wasm/{ => argon2}/argon2.js (100%) rename wasm/{ => argon2}/argon2.wasm (100%) rename wasm/{argon2-benchmark.js => argon2/benchmark.js} (70%) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 0f5c613..08e24cf 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -1999,27 +1999,29 @@ const testPlans = [ { name: "argon2-wasm", files: [ - "./wasm/argon2-bundle.js", - "./wasm/argon2.js", - "./wasm/argon2-benchmark.js" + "./wasm/argon2/argon2-bundle.js", + "./wasm/argon2/argon2.js", + "./wasm/argon2/benchmark.js" ], preload: { - argon2WasmBlob: "./wasm/argon2.wasm", + argon2WasmBlob: "./wasm/argon2/argon2.wasm", }, - benchmarkClass: WasmLegacyBenchmark, + benchmarkClass: WasmEMCCBenchmark, + iterations: 15, + worstCaseCount: 2, testGroup: WasmGroup }, { name: "argon2-wasm-simd", files: [ - "./wasm/argon2-bundle.js", - "./wasm/argon2.js", - "./wasm/argon2-benchmark.js" + "./wasm/argon2/argon2-bundle.js", + "./wasm/argon2/argon2.js", + "./wasm/argon2/benchmark.js" ], preload: { - argon2WasmSimdBlob: "./wasm/argon2-simd.wasm", + argon2WasmSimdBlob: "./wasm/argon2/argon2-simd.wasm", }, - benchmarkClass: WasmLegacyBenchmark, + benchmarkClass: WasmEMCCBenchmark, testGroup: WasmGroup }, // WorkerTests diff --git a/wasm/argon2-bundle.js b/wasm/argon2/argon2-bundle.js similarity index 100% rename from wasm/argon2-bundle.js rename to wasm/argon2/argon2-bundle.js diff --git a/wasm/argon2-simd.wasm b/wasm/argon2/argon2-simd.wasm similarity index 100% rename from wasm/argon2-simd.wasm rename to wasm/argon2/argon2-simd.wasm diff --git a/wasm/argon2.js b/wasm/argon2/argon2.js similarity index 100% rename from wasm/argon2.js rename to wasm/argon2/argon2.js diff --git a/wasm/argon2.wasm b/wasm/argon2/argon2.wasm similarity index 100% rename from wasm/argon2.wasm rename to wasm/argon2/argon2.wasm diff --git a/wasm/argon2-benchmark.js b/wasm/argon2/benchmark.js similarity index 70% rename from wasm/argon2-benchmark.js rename to wasm/argon2/benchmark.js index 3c82ca6..1bbd77d 100644 --- a/wasm/argon2-benchmark.js +++ b/wasm/argon2/benchmark.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Apple Inc. All rights reserved. + * Copyright (C) 2023-2024 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,22 +23,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -async function doRun() { - let start = benchmarkTime(); - if (!isInBrowser) { - globalThis.argon2WasmSimdBlob = Module.argon2WasmSimdBlob; - globalThis.argon2WasmBlob = Module.argon2WasmBlob; - } - - await instantiateArgon2WasmInstance(); - await testArgon2HashAndVerify(); - reportCompileTime(benchmarkTime() - start); +class Benchmark { + firstIteration = true; + async runIteration() { + if (this.firstIteration) { + this.firstIteration = false; + if (!isInBrowser) { + globalThis.argon2WasmSimdBlob = Module.argon2WasmSimdBlob; + globalThis.argon2WasmBlob = Module.argon2WasmBlob; + } - start = benchmarkTime(); + await instantiateArgon2WasmInstance(); + } - for (let i = 0; i < 5; ++i) - await testArgon2HashAndVerify(); - - reportRunTime(benchmarkTime() - start) -} + return await testArgon2HashAndVerify(); + } +};