From 60cf1f4da125221b618cdaf2e9a5cb71c9a7ff9f Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Mon, 3 Dec 2018 17:56:38 +0100 Subject: [PATCH] Add benchmarks --- x/mint/minter_test.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/x/mint/minter_test.go b/x/mint/minter_test.go index 3fd2bf39b56e..2bd50423e2b3 100644 --- a/x/mint/minter_test.go +++ b/x/mint/minter_test.go @@ -96,8 +96,36 @@ func BenchmarkBlockProvision(b *testing.B) { r1 := rand.New(s1) minter.AnnualProvisions = sdk.NewDec(r1.Int63n(1000000)) - // run the Fib function b.N times + // run the BlockProvision function b.N times for n := 0; n < b.N; n++ { minter.BlockProvision(params) } } + +// Next inflation benchmarking +// BenchmarkNextInflation-4 1000000 1828 ns/op +func BenchmarkNextInflation(b *testing.B) { + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + bondedRatio := sdk.NewDecWithPrec(1, 1) + + // run the NextInflationRate function b.N times + for n := 0; n < b.N; n++ { + minter.NextInflationRate(params, bondedRatio) + } + +} + +// Next annual provisions benchmarking +// BenchmarkNextAnnualProvisions-4 5000000251 ns/op +func BenchmarkNextAnnualProvisions(b *testing.B) { + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + totalSupply := sdk.NewDec(100000000000000) + + // run the NextAnnualProvisions function b.N times + for n := 0; n < b.N; n++ { + minter.NextAnnualProvisions(params, totalSupply) + } + +}