MCPcopy
hub / github.com/github/github-mcp-server / Start

Method Start

internal/profiler/profiler.go:138–170  ·  view source on GitHub ↗

Start begins timing an operation and returns a function to complete the profiling

(ctx context.Context, operation string)

Source from the content-addressed store, hash-verified

136
137// Start begins timing an operation and returns a function to complete the profiling
138func (p *Profiler) Start(ctx context.Context, operation string) func(lines int, bytes int64) *Profile {
139 if !p.enabled {
140 return func(int, int64) *Profile { return nil }
141 }
142
143 profile := &Profile{
144 Operation: operation,
145 Timestamp: time.Now(),
146 }
147
148 var memBefore runtime.MemStats
149 runtime.ReadMemStats(&memBefore)
150 profile.MemoryBefore = memBefore.Alloc
151
152 start := time.Now()
153
154 return func(lines int, bytes int64) *Profile {
155 profile.Duration = time.Since(start)
156 profile.LinesCount = lines
157 profile.BytesCount = bytes
158
159 var memAfter runtime.MemStats
160 runtime.ReadMemStats(&memAfter)
161 profile.MemoryAfter = memAfter.Alloc
162 profile.MemoryDelta = safeMemoryDelta(memAfter.Alloc, memBefore.Alloc)
163
164 if p.logger != nil {
165 p.logger.InfoContext(ctx, "Performance profile", "profile", profile.String())
166 }
167
168 return profile
169 }
170}
171
172var globalProfiler *Profiler
173

Callers 4

downloadLogContentFunction · 0.80
StartFunction · 0.80
openBrowserFunction · 0.80
executeServerCommandFunction · 0.80

Calls 2

StringMethod · 0.95
safeMemoryDeltaFunction · 0.85

Tested by

no test coverage detected