Benchmarks & Profiling: Measure Performance with pprof | Go Tutorial #30

11views
00
20:11
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Learn benchmarking and profiling in Go! Go's testing package includes powerful tools for measuring performance and finding bottlenecks - no external tools needed. 📚 What you'll learn: - Writing benchmark functions with func BenchmarkX(b *testing.B) - The classic for range b.N loop and modern b.Loop() (Go 1.24+) - Reading benchmark output (ns/op, -8 suffix, iterations) - Running specific benchmarks with -bench flag - -count flag for multiple runs - -benchmem for memory allocation stats (B/op, allocs/op) - Comparing implementations (+ operator vs Sprintf vs strings.Builder) - Table-driven benchmarks with b.Run() across input sizes - Sub-benchmark filtering with regex patterns - CPU profiling with -cpuprofile flag - Analyzing profiles with go tool pprof (top, flat vs cum) Benchmarking is essential for writing high-performance Go code! ⏱️ Timestamps: 0:00 - Introduction 0:30 - Benchmark Basics (b.N, b.Loop, ns/op, -count) 4:43 - Comparing Implementations (-benchmem, B/op, allocs/op) 8:54 - Table-Driven Benchmarks (b.Run, sub-benchmarks, filtering) 14:08 - CPU Profiling (cpuprofile, go tool pprof, top) 18:57 - Recap 19:27 - Up Next: HTTP Client 💻 Code: https://github.com/GoCelesteAI/go_benchmarks 🔔 Subscribe for more Go tutorials!

Tags

golanggoprogrammingtutorialbenchmarkingbenchmarksprofilingpprofgo testperformancetesting.Bb.Nb.Loopbenchmemcpu profiling
Back to tutorials

Duration

20:11

Published

February 5, 2026

Added to Codegiz

March 15, 2026

Open in YouTube