Go

Performance Optimization

Profiling, benchmarking, CPU profiling, memory profiling, bottleneck analysis, optimizations

22 면접 질문·
Senior
1

What is the pprof tool in Go?

답변

pprof is Go's built-in profiling tool that analyzes CPU, memory, goroutines and other metrics. It generates binary format profiles that can be analyzed with go tool pprof. This tool is essential for identifying performance bottlenecks and optimizing Go applications in production.

2

How to enable CPU profiling in a Go application?

답변

CPU profiling is enabled with pprof.StartCPUProfile(file) and stopped with pprof.StopCPUProfile(). This approach captures CPU usage during program execution. For web applications, using the net/http/pprof package automatically exposes profiling endpoints.

3

What is the difference between CPU profiling and memory profiling?

답변

CPU profiling measures time spent in each function to identify execution bottlenecks, while memory profiling measures memory allocations to detect leaks and excessive usage. CPU profiling uses sampling every 10ms by default, memory profiling captures all allocations or a sample depending on configuration.

4

How to create a benchmark in Go with the testing package?

5

What does the result '1000 ns/op' mean in a Go benchmark?

+19 면접 질문

다음 면접을 위해 Go을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기