Skip to content

Commit c395f3e

Browse files
committed
Bench: Extend test suite to handle #each reactivity profile
1 parent 1ba5e85 commit c395f3e

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

packages/component/bench/tachometer/bench-template-reactivity.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ defineComponent({
182182
}),
183183
});
184184

185+
// 1000-item flat each with five fields per item. Mount-only, no
186+
// mutations. Items signal stays at framework defaults so the
187+
// workload represents the path a typical author takes when
188+
// declaring a list without hand-tuning Signal options. Measures
189+
// per-record creation and Signal allocation cost on mount.
190+
defineComponent({
191+
tagName: 'bench-each-mount',
192+
renderingEngine: 'native',
193+
template:
194+
`{#each item in items}<div><span>{item.a}</span><span>{item.b}</span><span>{item.c}</span><span>{item.d}</span><span>{item.e}</span></div>{/each}`,
195+
defaultState: {
196+
items: Array.from({ length: 1000 }, (_, i) => ({
197+
id: `id-${i}`,
198+
a: `a${i}`,
199+
b: `b${i}`,
200+
c: `c${i}`,
201+
d: `d${i}`,
202+
e: `e${i}`,
203+
})),
204+
},
205+
});
206+
185207
/*******************************
186208
Bench Runner
187209
*******************************/
@@ -309,6 +331,22 @@ for (let i = 0; i < 50; i++) {
309331
performance.measure('active-indicator-nested-200', startMark('active-indicator-nested-200'));
310332
destroy();
311333

334+
/*******************************
335+
Each mount
336+
*******************************/
337+
338+
// Mark before createElement so the timer captures the entire mount
339+
// path: connectedCallback, fullRender, Renderer construction,
340+
// parseHTML, bindMarkers, and the each block's per-record creation.
341+
// No mutation cycle follows. Only mount cost is measured.
342+
// purpose: Mounts a fresh 1000-item each block with five-field items so per-record allocation cost dominates the wall clock.
343+
performance.mark(startMark('each-mount-1000'));
344+
const el10 = document.createElement('bench-each-mount');
345+
container.appendChild(el10);
346+
await flush();
347+
performance.measure('each-mount-1000', startMark('each-mount-1000'));
348+
destroy();
349+
312350
/*******************************
313351
Results
314352
*******************************/

packages/component/bench/tachometer/tachometer-ci-template-reactivity.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
{ "mode": "performance", "entryName": "stable-ref-mutate-500" },
1818
{ "mode": "performance", "entryName": "subtemplate-data-blob-100" },
1919
{ "mode": "performance", "entryName": "snippet-in-subtemplate-100" },
20-
{ "mode": "performance", "entryName": "active-indicator-nested-200" }
20+
{ "mode": "performance", "entryName": "active-indicator-nested-200" },
21+
{ "mode": "performance", "entryName": "each-mount-1000" }
2122
]
2223
},
2324
{
@@ -32,7 +33,8 @@
3233
{ "mode": "performance", "entryName": "stable-ref-mutate-500" },
3334
{ "mode": "performance", "entryName": "subtemplate-data-blob-100" },
3435
{ "mode": "performance", "entryName": "snippet-in-subtemplate-100" },
35-
{ "mode": "performance", "entryName": "active-indicator-nested-200" }
36+
{ "mode": "performance", "entryName": "active-indicator-nested-200" },
37+
{ "mode": "performance", "entryName": "each-mount-1000" }
3638
]
3739
}
3840
]

0 commit comments

Comments
 (0)