pick and place editing working, saving and loading working
This commit is contained in:
49
test/contextBench.test.ts
Normal file
49
test/contextBench.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
getContextItem,
|
||||
setContextItem,
|
||||
setDefaultContext,
|
||||
withContext,
|
||||
} from "../lib/context.ts"; // adjust path as needed
|
||||
import { testPerformance } from "./bench.ts";
|
||||
|
||||
/**
|
||||
* Benchmarks the performance of setting and getting context items.
|
||||
* All context transactions should run 10000 times within the 60 FPS frame time.
|
||||
* getContextItem should run 100000 times within the 240 FPS frame time to ensure adequate performance.
|
||||
*/
|
||||
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,
|
||||
);
|
||||
|
||||
testPerformance(
|
||||
() => {
|
||||
setContextItem("a", 1);
|
||||
},
|
||||
10000,
|
||||
60,
|
||||
);
|
||||
});
|
Reference in New Issue
Block a user