36 lines
591 B
JavaScript
36 lines
591 B
JavaScript
import {
|
|
getContextItem,
|
|
setDefaultContext,
|
|
withContext,
|
|
} from "@lib/context.ts"; // adjust path as needed
|
|
import { testPerformance } from "./bench.ts";
|
|
|
|
Deno.test("Context Benchmark", () => {
|
|
console.log("Context Benchmark - run within frame time");
|
|
testPerformance(
|
|
() => {
|
|
setDefaultContext({ a: 1 });
|
|
},
|
|
10000,
|
|
60,
|
|
);
|
|
|
|
testPerformance(
|
|
() => {
|
|
withContext({ a: 1 }, () => {
|
|
getContextItem("a");
|
|
});
|
|
},
|
|
10000,
|
|
60,
|
|
);
|
|
|
|
testPerformance(
|
|
() => {
|
|
getContextItem("a");
|
|
},
|
|
100000,
|
|
240,
|
|
);
|
|
});
|