Open History to see the last commit
1export type Framework = 'react' | 'solid' | 'vue'
2β
3export type MountedApp = {
4 router: unknown
5 unmount: () => void
6}
7β
8export type MountTestApp = (container: HTMLDivElement) => MountedApp
9β
10const frameworkNames = {
11 react: 'React',
12 solid: 'Solid',
13 vue: 'Vue',
14} satisfies Record<Framework, string>
15β
16export function noop() {}
17β
18export function warnClientMemoryDevMode(framework: Framework) {
19 if (process.env.NODE_ENV !== 'production') {
20 console.warn(
21 `memory client benchmark is running without NODE_ENV=production; ${frameworkNames[framework]} dev overhead will dominate results.`,
22 )
23 }
24}
25β
26export function createBenchContainer() {
27 const container = document.createElement('div')
28 document.body.append(container)
29β
30 return container
31}
32β
33export function removeBenchContainer(container: HTMLDivElement | undefined) {
34 container?.remove()
35}
36β
37export function nextAnimationFrame() {
38 return new Promise<void>((resolve) => {
39 requestAnimationFrame(() => resolve())
40 })
41}
42β
43export async function drainMicrotasks() {
44 await Promise.resolve()
45 await Promise.resolve()
46}