MCPcopy
hub / github.com/vitejs/vite / runBenchmark

Function runBenchmark

packages/vite/scripts/benchCircularImport.ts:147–188  ·  view source on GitHub ↗
(config: GraphConfig)

Source from the content-addressed store, hash-verified

145}
146
147async function runBenchmark(config: GraphConfig): Promise<BenchResult> {
148 const graph = generateGraph(config)
149
150 let edgeCount = 0
151 for (const deps of graph.edges.values()) {
152 edgeCount += deps.length
153 }
154
155 const server = await createServer({
156 configFile: false,
157 // eslint-disable-next-line n/no-unsupported-features/node-builtins
158 root: import.meta.dirname,
159 logLevel: 'error',
160 server: {
161 middlewareMode: true,
162 ws: false,
163 },
164 optimizeDeps: {
165 noDiscovery: true,
166 include: [],
167 },
168 plugins: [createBenchPlugin(graph)],
169 })
170
171 const runner = createServerModuleRunner(server.environments.ssr, {
172 hmr: false,
173 sourcemapInterceptor: false,
174 })
175
176 const start = performance.now()
177 await runner.import(graph.entry)
178 const timeMs = performance.now() - start
179
180 await runner.close()
181 await server.close()
182
183 return {
184 moduleCount: config.moduleCount,
185 edgeCount,
186 timeMs,
187 }
188}
189
190// ---------------------------------------------------------------------------
191// Main

Callers 1

mainFunction · 0.85

Calls 6

createServerFunction · 0.90
createServerModuleRunnerFunction · 0.90
generateGraphFunction · 0.85
createBenchPluginFunction · 0.85
importMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected