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

Function stopProfiler

packages/vite/src/node/cli.ts:68–92  ·  view source on GitHub ↗
(
  log: (message: string) => void,
)

Source from the content-addressed store, hash-verified

66let profileCount = 0
67
68export const stopProfiler = (
69 log: (message: string) => void,
70): void | Promise<void> => {
71 if (!profileSession) return
72 return new Promise((res, rej) => {
73 profileSession!.post('Profiler.stop', (err, { profile }) => {
74 // Write profile to disk, upload, etc.
75 if (!err) {
76 const outPath = path.resolve(
77 `./vite-profile-${profileCount++}.cpuprofile`,
78 )
79 fs.writeFileSync(outPath, JSON.stringify(profile))
80 log(
81 colors.yellow(
82 `CPU profile written to ${colors.white(colors.dim(outPath))}`,
83 ),
84 )
85 profileSession = undefined
86 res()
87 } else {
88 rej(err)
89 }
90 })
91 })
92}
93
94const filterDuplicateOptions = <T extends object>(options: T) => {
95 for (const [key, value] of Object.entries(options)) {

Callers 2

actionFunction · 0.85
cli.tsFile · 0.85

Calls 2

logFunction · 0.85
resolveMethod · 0.65

Tested by

no test coverage detected