A simple Go benchmarking tool to measure optimal goroutine counts for CPU and memory-intensive operations.
go install github.com/lab1702/go-bench@latestgit clone https://github.com/lab1702/go-bench.git
cd go-bench
go build# Run both CPU and memory benchmarks (default)
go-bench
# Run only CPU benchmark
go-bench -t cpu
# Run only memory benchmark
go-bench -t memory
# Adjust test duration (in seconds)
go-bench -d 5-t: Type of test to run (cpu,memory, orboth). Default:both-d: Duration of each test configuration in seconds. Default:10
The tool benchmarks your system with different goroutine counts to find the optimal configuration:
- 1 goroutine (baseline single-threaded performance)
- Logical CPUs / 2
- Logical CPUs
- Logical CPUs * 1.5
- Logical CPUs * 2
For each configuration, it measures:
- Operations per second
- Total operations completed
- Speed increase compared to single goroutine
- CPU ratio (goroutines / Logical CPUs)
The tool provides:
- Real-time progress during benchmarking
- Detailed results table for each configuration
- Summary of optimal configuration
- Performance comparison against single-threaded baseline
- Go 1.25 or higher
MIT License - see LICENSE file for details