
Performance Optimization
Profiling, benchmarking, CPU profiling, memory profiling, bottleneck analysis, optimizations
1What is the pprof tool in Go?
What is the pprof tool in Go?
Câu trả lời
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.
2How to enable CPU profiling in a Go application?
How to enable CPU profiling in a Go application?
Câu trả lời
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.
3What is the difference between CPU profiling and memory profiling?
What is the difference between CPU profiling and memory profiling?
Câu trả lời
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.
How to create a benchmark in Go with the testing package?
What does the result '1000 ns/op' mean in a Go benchmark?
+19 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Go khác
Go Basics
Go Data Structures
Go Interfaces
Error Handling
Goroutines Basics
Channels
Go Modules
HTTP Server
HTTP Client
JSON Encoding
database/sql
Context Package
Testing
Concurrency Patterns
Sync Primitives
Go Web Frameworks
REST API Design
gRPC
Reflection
Memory Management
Generics
Go Design Patterns
Microservices
Security & Authentication
Docker & Containerization
Kubernetes Basics
Advanced Go
CLI Development
Nắm vững Go cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí