@@ -24,20 +24,34 @@ const tableProps = {
2424 externalScroll : false
2525} as const
2626
27+ // CodSpeed runs these under a simulator that counts instructions, and GitHub's
28+ // hosted runners alternate between Intel and AMD CPUs whose cache sizes make
29+ // glibc select different string routines. Anything under ~1ms picks up phantom
30+ // regressions from that alone, so every bench body repeats its work enough to
31+ // clear the bar. Scaling every group by the same factor keeps the ratios that
32+ // these benchmarks exist to compare.
33+ const ITERATIONS = 100
34+
2735// Building the factory is the expensive step (deep-merges the whole variant
2836// matrix, joins every slot, flattens compound variants). Today it happens inside
2937// each component's `computed`, so every variant-prop change re-runs it.
3038describe ( 'factory build' , ( ) => {
3139 bench ( 'button (~6 slots)' , ( ) => {
32- tv ( { extend : buttonTheme } )
40+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
41+ tv ( { extend : buttonTheme } )
42+ }
3343 } )
3444
3545 bench ( 'table (~13 slots)' , ( ) => {
36- tv ( { extend : tableTheme } )
46+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
47+ tv ( { extend : tableTheme } )
48+ }
3749 } )
3850
3951 bench ( 'navigation-menu (~31 slots)' , ( ) => {
40- tv ( { extend : navigationMenuTheme } )
52+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
53+ tv ( { extend : navigationMenuTheme } )
54+ }
4155 } )
4256} )
4357
@@ -48,11 +62,15 @@ describe('invocation (prebuilt factory)', () => {
4862 const tableFactory = tv ( { extend : tableTheme } )
4963
5064 bench ( 'button' , ( ) => {
51- buttonFactory ( buttonProps )
65+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
66+ buttonFactory ( buttonProps )
67+ }
5268 } )
5369
5470 bench ( 'table' , ( ) => {
55- tableFactory ( tableProps )
71+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
72+ tableFactory ( tableProps )
73+ }
5674 } )
5775} )
5876
@@ -61,11 +79,15 @@ describe('invocation (prebuilt factory)', () => {
6179// hoisting factory construction out of the per-variant-prop recomputation.
6280describe ( 'build + invoke (current fused pattern)' , ( ) => {
6381 bench ( 'button' , ( ) => {
64- tv ( { extend : buttonTheme } ) ( buttonProps )
82+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
83+ tv ( { extend : buttonTheme } ) ( buttonProps )
84+ }
6585 } )
6686
6787 bench ( 'table' , ( ) => {
68- tv ( { extend : tableTheme } ) ( tableProps )
88+ for ( let i = 0 ; i < ITERATIONS ; i ++ ) {
89+ tv ( { extend : tableTheme } ) ( tableProps )
90+ }
6991 } )
7092} )
7193
0 commit comments