all: ensure b.ReportAllocs() in all the benchmarks (#8460)
With this change, we'll get details on the number of allocations performed by code. Later on when we have continuous benchmarking infrastructure, this change will prove useful to flag regressions. Fixes #8459 Co-authored-by: Alessio Treglia <alessio@tendermint.com>
This commit is contained in:
co-authored by
Alessio Treglia
parent
580e9681a5
commit
784a9a69a1
@@ -158,6 +158,8 @@ func TestUnarmorInfoBytesErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkBcryptGenerateFromPassword(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
passphrase := []byte("passphrase")
|
||||
for securityParam := 9; securityParam < 16; securityParam++ {
|
||||
param := securityParam
|
||||
|
||||
@@ -25,6 +25,7 @@ func (zeroReader) Read(buf []byte) (int, error) {
|
||||
// BenchmarkKeyGeneration benchmarks the given key generation algorithm using
|
||||
// a dummy reader.
|
||||
func BenchmarkKeyGeneration(b *testing.B, generateKey func(reader io.Reader) types.PrivKey) {
|
||||
b.ReportAllocs()
|
||||
var zero zeroReader
|
||||
for i := 0; i < b.N; i++ {
|
||||
generateKey(zero)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func BenchmarkKeyGeneration(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkKeygenWrapper := func(reader io.Reader) types.PrivKey {
|
||||
priv := genPrivKey(reader)
|
||||
return &PrivKey{Key: priv}
|
||||
@@ -17,11 +18,13 @@ func BenchmarkKeyGeneration(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkSigning(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
priv := GenPrivKey()
|
||||
benchmarking.BenchmarkSigning(b, priv)
|
||||
}
|
||||
|
||||
func BenchmarkVerification(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
priv := GenPrivKey()
|
||||
benchmarking.BenchmarkVerification(b, priv)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user