Skip to content

Commit a1f8ea4

Browse files
bench: construct subjects don't return proxies to await (#3926)
* bench: construct subjects don't return proxies to await The CodSpeed analysis runner times `await fn()`; a subject returning a merge/omit view had its `.then` probed through the proxy (and store) traps inside the timed window. Assign results to a module-level sink. Co-authored-by: Cursor <[email protected]> * bench: one sink per utilities subject A shared sink took objects, arrays, booleans and numbers across subjects; the primitive-returning read subjects measured 5-9% slower under it. Co-authored-by: Cursor <[email protected]> * Revert "bench: one sink per utilities subject" This reverts commit 2e46cf6. --------- Co-authored-by: Cursor <[email protected]>
1 parent 24d0fb5 commit a1f8ea4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/signals/tests/store/utilities.bench.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const createStoreObject = (amount: number) => {
4747
return state;
4848
};
4949

50+
// The harness times `await fn()`: a returned merge/omit view would have its
51+
// `.then` probed through the proxy traps inside the timed window. Subjects
52+
// hand their result here instead, which also keeps it live.
53+
let sink: unknown;
54+
5055
type Test = {
5156
title: string;
5257
benchs: { title: string; func: any }[];
@@ -79,7 +84,9 @@ function createTest<G extends (...args: any[]) => any>(options: {
7984
for (const subject of options.subjects) {
8085
test.benchs.push({
8186
title: subject.name,
82-
func: () => subject.func(...args)
87+
func: () => {
88+
sink = subject.func(...args);
89+
}
8390
});
8491
}
8592
tests.push(test);

0 commit comments

Comments
 (0)