Your Code is Pretty. Your CPU Doesn't Care.
A side-by-side comparison of linter-perfect code vs CPU-perfect code, profiled with pprof, benchmarked with real numbers. One million transactions, two architectures, one uncomfortable truth: 63% of the runtime was garbage collection. The code review said "looks good to me."
go build -o profile-party .
./profile-partychmod +x profile.sh
./profile.shThis generates CPU + heap profiles for both versions, runs benchmarks, and tells you how to explore with pprof.
| Pretty | Fast | Factor | |
|---|---|---|---|
| Time | 107 ms | 28 ms | 3.8x |
| Memory | 101.5 MB | 3.6 MB | 28x |
| Allocations | 282 | 7 | 40x |
| GC CPU | 63% | 0% | --- |
The full tutorial lives at the GitHub Pages site:
https://copyleftdev.github.io/profile-party
pretty.go # The linter's favorite — interfaces, pipelines, string types
fast.go # The CPU's favorite — struct-of-arrays, integers, one pass
main.go # Generates 1M records, runs both, prints the verdict
bench_test.go # go test -bench with memory reporting
profile.sh # One script to profile everything
article.md # Article source (Markdown)
docs/ # GitHub Pages site
- Push this repo to GitHub
- Go to Settings > Pages
- Source: Deploy from a branch
- Branch:
main, folder:/docs - Save — your site goes live in ~60 seconds
Every push to main:
- Build & Benchmark — compiles the Go code, runs the comparison, executes benchmarks
- Deploy — publishes
docs/to GitHub Pages viaactions/deploy-pages
PRs get the build + benchmark gate without deploying.
MIT
