Skip to content

Commit

Permalink
test: fix api calls for Deno v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jlong145 committed Oct 17, 2024
1 parent e5e2480 commit 5868536
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
13 changes: 4 additions & 9 deletions benchmark/hyperfine/parallel_perf_bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
20 changes: 13 additions & 7 deletions benchmark/wasm_instance_start_bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/path/mod.ts";
import { readAllSync } from "https://deno.land/std/io/read_all.ts";

class TestExample extends WorkerDefinition {
public constructor() {
super();
Expand All @@ -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<TestExample> = new InstanceWrapper<
TestExample
Expand All @@ -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);
},
Expand All @@ -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<TestExample> = new InstanceWrapper<
TestExample
>(
Expand All @@ -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);
},
Expand All @@ -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");
}
Expand All @@ -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);
},
Expand Down

0 comments on commit 5868536

Please sign in to comment.