Toy project to practice benchmarking with the Go programming language.
Compare memory and runtime of three fibonacci
functions.
- The naive recursive approach
- An iterative approach, using a slice.
- An optimized iterative approach with a fixed number of variables.
Run the benchmark with:
go test -bench=. -benchmem > benchmark/raw.txt
Results on goos: darwin
and goarch: amd64
available in ./benchmark/raw.txt
.
- How to write benchmarks in Go, from Dave Cheney
- Cracking the Coding Interview, chapter 8, Dynamic Programming
Benchmark analysis in my article (french)