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:
Emmanuel T Odeke
2021-01-27 23:52:08 -08:00
committed by GitHub
co-authored by Alessio Treglia
parent 580e9681a5
commit 784a9a69a1
15 changed files with 25 additions and 0 deletions
+3
View File
@@ -89,6 +89,7 @@ func TestBlockProvision(t *testing.T) {
// using sdk.Dec operations: (current implementation)
// BenchmarkBlockProvision-4 3000000 429 ns/op
func BenchmarkBlockProvision(b *testing.B) {
b.ReportAllocs()
minter := InitialMinter(sdk.NewDecWithPrec(1, 1))
params := DefaultParams()
@@ -105,6 +106,7 @@ func BenchmarkBlockProvision(b *testing.B) {
// Next inflation benchmarking
// BenchmarkNextInflation-4 1000000 1828 ns/op
func BenchmarkNextInflation(b *testing.B) {
b.ReportAllocs()
minter := InitialMinter(sdk.NewDecWithPrec(1, 1))
params := DefaultParams()
bondedRatio := sdk.NewDecWithPrec(1, 1)
@@ -119,6 +121,7 @@ func BenchmarkNextInflation(b *testing.B) {
// Next annual provisions benchmarking
// BenchmarkNextAnnualProvisions-4 5000000 251 ns/op
func BenchmarkNextAnnualProvisions(b *testing.B) {
b.ReportAllocs()
minter := InitialMinter(sdk.NewDecWithPrec(1, 1))
params := DefaultParams()
totalSupply := sdk.NewInt(100000000000000)