MCPcopy
hub / github.com/vuejs/core / benchWithBranches

Function benchWithBranches

packages/reactivity/__benchmarks__/effect.bench.ts:76–92  ·  view source on GitHub ↗
(size: number)

Source from the content-addressed store, hash-verified

74 benchWithRefs(1000)
75
76 function benchWithBranches(size: number) {
77 const toggle = ref(true)
78 const refs: Ref[] = []
79 for (let i = 0; i < size; i++) {
80 refs.push(ref(i))
81 }
82 effect(() => {
83 if (toggle.value) {
84 for (let i = 0; i < size; i++) {
85 refs[i].value
86 }
87 }
88 })
89 bench(`${size} refs branch toggle`, () => {
90 toggle.value = !toggle.value
91 })
92 }
93
94 benchWithBranches(10)
95 benchWithBranches(100)

Callers 1

effect.bench.tsFile · 0.85

Calls 3

effectFunction · 0.85
pushMethod · 0.65
refFunction · 0.50

Tested by

no test coverage detected