MCPcopy
hub / github.com/claude-code-best/claude-code / logStartupPerf

Function logStartupPerf

src/utils/startupProfiler.ts:166–201  ·  view source on GitHub ↗

* Log startup performance phases to Statsig. * Only logs if this session was sampled at startup.

()

Source from the content-addressed store, hash-verified

164 * Only logs if this session was sampled at startup.
165 */
166function logStartupPerf(): void {
167 // Only log if we were sampled (decision made at module load)
168 if (!STATSIG_LOGGING_SAMPLED) return
169
170 const perf = getPerformance()
171 const marks = perf.getEntriesByType('mark')
172 if (marks.length === 0) return
173
174 // Build checkpoint lookup
175 const checkpointTimes = new Map<string, number>()
176 for (const mark of marks) {
177 checkpointTimes.set(mark.name, mark.startTime)
178 }
179
180 // Compute phase durations
181 const metadata: Record<string, number | undefined> = {}
182
183 for (const [phaseName, [startCheckpoint, endCheckpoint]] of Object.entries(
184 PHASE_DEFINITIONS,
185 )) {
186 const startTime = checkpointTimes.get(startCheckpoint)
187 const endTime = checkpointTimes.get(endCheckpoint)
188
189 if (startTime !== undefined && endTime !== undefined) {
190 metadata[`${phaseName}_ms`] = Math.round(endTime - startTime)
191 }
192 }
193
194 // Add checkpoint count for debugging
195 metadata.checkpoint_count = marks.length
196
197 logEvent(
198 'tengu_startup_perf',
199 metadata as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
200 )
201}

Callers 1

profileReportFunction · 0.85

Calls 6

getPerformanceFunction · 0.85
logEventFunction · 0.85
getEntriesByTypeMethod · 0.80
setMethod · 0.80
entriesMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected