diff --git a/benchmark/hyperfine/parallel_perf_bench.ts b/benchmark/hyperfine/parallel_perf_bench.ts index 2e5d22c..0c88667 100644 --- a/benchmark/hyperfine/parallel_perf_bench.ts +++ b/benchmark/hyperfine/parallel_perf_bench.ts @@ -31,18 +31,13 @@ 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++) { - example.execute("getKeyPair", {}); - } - - while ( - example.pool?.getThreadStates().find((s) => s.tasks.length > 0) - ) { - // just wait for the results of the pool - await new Promise((res) => setTimeout(res, 1)); + promises.push(example.execute("getKeyPair", {})); } + await Promise.all(promises); example.terminateWorker(); } diff --git a/benchmark/wasm_instance_start_bench.ts b/benchmark/wasm_instance_start_bench.ts index 06c4a0a..f7ceca5 100644 --- a/benchmark/wasm_instance_start_bench.ts +++ b/benchmark/wasm_instance_start_bench.ts @@ -2,6 +2,7 @@ import { InstanceWrapper, WorkerDefinition } from "../src/mod.ts"; import { existsSync } from "https://deno.land/std/fs/mod.ts"; import * as path from "https://deno.land/std@0.188.0/path/mod.ts"; import { readAllSync } from "https://deno.land/std/io/read_all.ts"; + class TestExample extends WorkerDefinition { public constructor() { super(); @@ -23,6 +24,8 @@ Deno.bench("Wasm Worker Start Go Module loading", { group: "non imported initalization", }, 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 wrapper: InstanceWrapper = new InstanceWrapper< TestExample @@ -32,9 +35,9 @@ Deno.bench("Wasm Worker Start Go Module loading", { outputPath: "output", namespace: "testing", addons: [ - "./lib/wasm_exec_tiny.js", + wasmLibPath, ], - modulePath: "./examples/wasm/tiny-go/primes-2.wasm", + modulePath: wasmModulePath, addonLoader: (path: string) => { return Deno.readTextFileSync(path); }, @@ -57,7 +60,8 @@ Deno.bench("Wasm Worker Start Rust Module loading", { group: "non imported initalization", }, 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 wrapper: InstanceWrapper = new InstanceWrapper< TestExample >( @@ -66,9 +70,9 @@ Deno.bench("Wasm Worker Start Rust Module loading", { outputPath: "output", namespace: "asd", addons: [ - "./lib/wasm_test.js", + wasmLibPath ], - modulePath: "./examples/wasm/rust/wasm_test_bg.wasm", + modulePath: wasmModulePath, addonLoader: (path: string) => { return Deno.readTextFileSync(path); }, @@ -90,6 +94,8 @@ Deno.bench("Wasm Worker Start Rust Module loading", { 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"); if (!existsSync("./public")) { Deno.mkdirSync("./public"); } @@ -108,9 +114,9 @@ Deno.bench("Wasm Worker Start Code Gen Bootstrapping Rust", { outputPath: "./public/bench", namespace: "asd", addons: [ - "./lib/wasm_test.js", + wasmLibPath, ], - modulePath: "./examples/wasm/rust/wasm_test_bg.wasm", + modulePath: wasmModulePath, addonLoader: (path: string) => { return Deno.readTextFileSync(path); },