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

Function logStartupPerf

src/utils/startupProfiler.ts:159–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

profileReportFunction · 0.85

Calls 5

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

Tested by

no test coverage detected