MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / heapProfiling

Function heapProfiling

tools/cache_perf_tool/main.go:402–427  ·  view source on GitHub ↗
(ctx context.Context, interval time.Duration)

Source from the content-addressed store, hash-verified

400}
401
402func heapProfiling(ctx context.Context, interval time.Duration) {
403 ticker := time.NewTicker(interval)
404 defer ticker.Stop()
405 numGoroutines.Add(1)
406 defer numGoroutines.Add(-1)
407 for {
408 select {
409 case <-ctx.Done():
410 return
411 case <-ticker.C:
412 fileName := fmt.Sprintf("heap-%s.prof", time.Now().Format(time.RFC3339))
413 heapProfBuf := bytes.Buffer{}
414 err := pprof.WriteHeapProfile(&heapProfBuf)
415 if err != nil {
416 log.Printf("Error writing heap profile: %v", err)
417 return
418 }
419
420 err = os.WriteFile(fileName, heapProfBuf.Bytes(), os.ModePerm)
421 if err != nil {
422 log.Printf("Error writing heap profile to file: %v", err)
423 return
424 }
425 }
426 }
427}
428
429func mutexProfiling(ctx context.Context, interval time.Duration) {
430 ticker := time.NewTicker(interval)

Callers 1

mainFunction · 0.85

Calls 3

DoneMethod · 0.80
StopMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected