Skip to content

Commit

Permalink
Add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Dec 3, 2018
1 parent b556c88 commit 60cf1f4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion x/mint/minter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}

0 comments on commit 60cf1f4

Please sign in to comment.