MCPcopy Create free account
hub / github.com/chakra-ui/panda / stopProfiling

Function stopProfiling

packages/node/src/cpu-profile.ts:58–88  ·  view source on GitHub ↗
(cb?: () => void)

Source from the content-addressed store, hash-verified

56 }
57
58 const stopProfiling = (cb?: () => void) => {
59 if (state !== 'profiling') {
60 cb?.()
61 return
62 }
63
64 setState('stopping')
65 session.post('Profiler.stop', (err, params) => {
66 setState('idle')
67
68 if (err) {
69 logger.error('cpu-prof', err)
70 cb?.()
71 return
72 }
73
74 if (!params?.profile) {
75 cb?.()
76 return
77 }
78
79 const date = new Date()
80 const timestamp = date.toISOString().replace(/[-:.]/g, '')
81 const title = `panda-${prefix}-${timestamp}`
82
83 const outfile = path.join(cwd, `${title}.cpuprofile`)
84 fs.writeFileSync(outfile, JSON.stringify(params.profile))
85 logger.info('cpu-prof', outfile)
86 cb?.()
87 })
88 }
89
90 return stopProfiling
91}

Callers 2

toggleProfilerFunction · 0.70
startProfilingFunction · 0.70

Calls 3

setStateFunction · 0.85
joinMethod · 0.65
writeFileSyncMethod · 0.65

Tested by

no test coverage detected