MCPcopy Create free account
hub / github.com/Noumena-Network/code / getReport

Function getReport

src/utils/startupProfiler.ts:82–120  ·  view source on GitHub ↗

* Get a formatted report of all checkpoints * Only available when DETAILED_PROFILING is enabled

()

Source from the content-addressed store, hash-verified

80 * Only available when DETAILED_PROFILING is enabled
81 */
82function getReport(): string {
83 if (!DETAILED_PROFILING) {
84 return 'Startup profiling not enabled'
85 }
86
87 const perf = getPerformance()
88 const marks = perf.getEntriesByType('mark')
89 if (marks.length === 0) {
90 return 'No profiling checkpoints recorded'
91 }
92
93 const lines: string[] = []
94 lines.push('='.repeat(80))
95 lines.push('STARTUP PROFILING REPORT')
96 lines.push('='.repeat(80))
97 lines.push('')
98
99 let prevTime = 0
100 for (const [i, mark] of marks.entries()) {
101 lines.push(
102 formatTimelineLine(
103 mark.startTime,
104 mark.startTime - prevTime,
105 mark.name,
106 memorySnapshots[i],
107 8,
108 7,
109 ),
110 )
111 prevTime = mark.startTime
112 }
113
114 const lastMark = marks[marks.length - 1]
115 lines.push('')
116 lines.push(`Total startup time: ${formatMs(lastMark?.startTime ?? 0)}ms`)
117 lines.push('='.repeat(80))
118
119 return lines.join('\n')
120}
121
122let reported = false
123

Callers 1

profileReportFunction · 0.85

Calls 4

getPerformanceFunction · 0.85
formatTimelineLineFunction · 0.85
formatMsFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected