etcd-io / bbolt

An embedded key/value database for Go.
https://go.etcd.io/bbolt
MIT License
8.32k stars 644 forks source link

add gobench output option #765

Closed tjungblu closed 5 months ago

tjungblu commented 5 months ago

This replicates the output of testing.B, so it can be used with other tools. Example output:

bench -count 100000 -batch-size 25000 -profile-mode w -gobench-output
starting write benchmark.
Starting write iteration 0
Finished write iteration 0
Starting write iteration 25000
Finished write iteration 25000
Starting write iteration 50000
Finished write iteration 50000
Starting write iteration 75000
Finished write iteration 75000
starting read benchmark.
Write     100000               730.0 ns/op
Read    104900000                9.534 ns/op

The alignment is a bit annoying, but the format specification just says there must be spaces between.

ahrtr commented 5 months ago

Thanks @tjungblu for the enhancement. Overall looks good to me. cc @ivanvc to take a look.

Write     100000               730.0 ns/op
Read    104900000                9.534 ns/op

The alignment is a bit annoying,

It's because golang hard codes the width 8. Obviously the width of 104900000 is 9 https://github.com/golang/go/blob/45967bb18e04fa6dc62c2786c87ce120443c64f6/src/testing/benchmark.go#L419

ivanvc commented 5 months ago

Wow, thanks for the quick turnaround. I was about to start researching this :smile:. I want to test it with benchstat, which I will do later today.

Cross-linking #750.

tjungblu commented 5 months ago

yep, let me know how it goes.