From 105f2ab931d4258c655eec87c52abfc26258ba65 Mon Sep 17 00:00:00 2001 From: jlong145 <joshlong0795@gmail.com> Date: Thu, 17 Oct 2024 12:05:18 -0400 Subject: [PATCH] ref: small fixes --- benchmark/hyperfine/parallel_perf_bench.ts | 2 +- benchmark/wasm_instance_start_bench.ts | 30 +++++++++++++++++----- src/Pool.ts | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/benchmark/hyperfine/parallel_perf_bench.ts b/benchmark/hyperfine/parallel_perf_bench.ts index 0c88667..270f41e 100644 --- a/benchmark/hyperfine/parallel_perf_bench.ts +++ b/benchmark/hyperfine/parallel_perf_bench.ts @@ -31,7 +31,7 @@ async function parallelKeygenTest(opCount: number, workerCount: number) { }); await wrapper.start(); // Only measure time of execution. we Init shouldnt count ;) - + const promises = []; for (let i = 0; i < opCount; i++) { promises.push(example.execute("getKeyPair", {})); diff --git a/benchmark/wasm_instance_start_bench.ts b/benchmark/wasm_instance_start_bench.ts index f7ceca5..cd5d4c6 100644 --- a/benchmark/wasm_instance_start_bench.ts +++ b/benchmark/wasm_instance_start_bench.ts @@ -25,7 +25,13 @@ Deno.bench("Wasm Worker Start Go Module loading", { }, async (_b) => { const example = new TestExample(); const wasmLibPath = path.join(Deno.cwd(), "lib", "wasm_exec_tiny.js"); - const wasmModulePath = path.join(Deno.cwd(), "examples", "wasm", "tiny-go", "primes-2.wasm"); + const wasmModulePath = path.join( + Deno.cwd(), + "examples", + "wasm", + "tiny-go", + "primes-2.wasm", + ); const wrapper: InstanceWrapper<TestExample> = new InstanceWrapper< TestExample @@ -37,7 +43,7 @@ Deno.bench("Wasm Worker Start Go Module loading", { addons: [ wasmLibPath, ], - modulePath: wasmModulePath, + modulePath: wasmModulePath, addonLoader: (path: string) => { return Deno.readTextFileSync(path); }, @@ -61,7 +67,13 @@ Deno.bench("Wasm Worker Start Rust Module loading", { }, async (_b) => { const example = new TestExample(); const wasmLibPath = path.join(Deno.cwd(), "lib", "wasm_test.js"); - const wasmModulePath = path.join(Deno.cwd(), "examples", "wasm", "rust", "wasm_test_bg.wasm"); + const wasmModulePath = path.join( + Deno.cwd(), + "examples", + "wasm", + "rust", + "wasm_test_bg.wasm", + ); const wrapper: InstanceWrapper<TestExample> = new InstanceWrapper< TestExample >( @@ -70,9 +82,9 @@ Deno.bench("Wasm Worker Start Rust Module loading", { outputPath: "output", namespace: "asd", addons: [ - wasmLibPath + wasmLibPath, ], - modulePath: wasmModulePath, + modulePath: wasmModulePath, addonLoader: (path: string) => { return Deno.readTextFileSync(path); }, @@ -95,7 +107,13 @@ Deno.bench("Wasm Worker Start Code Gen Bootstrapping Rust", { group: "imported initalization", }, async (_b) => { const wasmLibPath = path.join(Deno.cwd(), "lib", "wasm_test.js"); - const wasmModulePath = path.join(Deno.cwd(), "examples", "wasm", "rust", "wasm_test_bg.wasm"); + const wasmModulePath = path.join( + Deno.cwd(), + "examples", + "wasm", + "rust", + "wasm_test_bg.wasm", + ); if (!existsSync("./public")) { Deno.mkdirSync("./public"); } diff --git a/src/Pool.ts b/src/Pool.ts index 94f6b02..da5795e 100644 --- a/src/Pool.ts +++ b/src/Pool.ts @@ -37,7 +37,7 @@ export class Pool { findWorkerForId = (id: string): WorkerHandler | undefined => { for (let i = 0; i < this.threads.length; i++) { - if (this.threads[i]._executionMap[id]) { + if (Object.keys(this.threads[i]._executionMap).indexOf(id) > -1) { return this.threads[i]; } }