MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / main

Function main

benchmarks/aggregate-benchmarks.mjs:165–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163}
164
165async function main() {
166 const inputFiles = await resolveInputFiles()
167
168 if (inputFiles.length === 0) {
169 throw new Error('No benchmark result files were found to aggregate.')
170 }
171
172 const allRuns = await Promise.all(
173 inputFiles.map(async (inputFile) => JSON.parse(await readFile(inputFile, 'utf8'))),
174 )
175 const { selectedRuns: runs, generationLabel } = resolveGenerationSelection(allRuns)
176
177 if (runs.length === 0) {
178 throw new Error('No benchmark result files matched the requested generation filter.')
179 }
180
181 const counts = Array.from(new Set(runs.flatMap((run) => run.counts ?? []))).sort(
182 (left, right) => left - right,
183 )
184
185 const summary = counts.map((count) => {
186 const rows = runs
187 .map((run) => run.summary?.find((entry) => entry.count === count))
188 .filter(Boolean)
189
190 const aggregateVersion = (version) => ({
191 mount: aggregateNumbers(rows.map((row) => row[version]?.mount?.median)),
192 unmount: aggregateNumbers(rows.map((row) => row[version]?.unmount?.median)),
193 update: aggregateNumbers(rows.map((row) => row[version]?.update?.median)),
194 mountMemory: aggregateNumbers(rows.map((row) => row[version]?.mountMemory?.median)),
195 unmountMemory: aggregateNumbers(rows.map((row) => row[version]?.unmountMemory?.median)),
196 timeoutCount: rows.reduce((total, row) => total + (row[version]?.timeoutCount ?? 0), 0),
197 })
198
199 const v5 = aggregateVersion('v5')
200 const v6 = aggregateVersion('v6')
201 const sampleCount = Math.max(v5.mount.sampleCount, v6.mount.sampleCount)
202
203 const mountDeltaMs =
204 typeof v5.mount.median === 'number' && typeof v6.mount.median === 'number'
205 ? v6.mount.median - v5.mount.median
206 : null
207 const unmountDeltaMs =
208 typeof v5.unmount.median === 'number' && typeof v6.unmount.median === 'number'
209 ? v6.unmount.median - v5.unmount.median
210 : null
211 const mountMemoryDeltaBytes =
212 typeof v5.mountMemory.median === 'number' && typeof v6.mountMemory.median === 'number'
213 ? v6.mountMemory.median - v5.mountMemory.median
214 : null
215 const unmountMemoryDeltaBytes =
216 typeof v5.unmountMemory.median === 'number' && typeof v6.unmountMemory.median === 'number'
217 ? v6.unmountMemory.median - v5.unmountMemory.median
218 : null
219 const updateDeltaMs =
220 typeof v5.update.median === 'number' && typeof v6.update.median === 'number'
221 ? v6.update.median - v5.update.median
222 : null

Callers 1

Calls 5

resolveInputFilesFunction · 0.85
aggregateVersionFunction · 0.70
timestampIdFunction · 0.70
buildMarkdownReportFunction · 0.70

Tested by

no test coverage detected