Benchmark the initialization cost of your packages or programs.
go get -u mvdan.cc/benchinit
This includes the cost of
init functions, plus initialising globals. In other
words, a package's contribution to the slowness before
main is run.
Benchmarking a single package is simple:
You can also include all dependencies in the benchmark:
benchinit -r cmd/go
Finally, like any other benchmark, you can pass in
go test flags:
benchinit -r -count=5 -benchtime=2s cmd/go