-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved benchmark test into its own file
- Loading branch information
Showing
2 changed files
with
29 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package keeper_test | ||
|
||
import "testing" | ||
|
||
func BenchmarkGetValidator(b *testing.B) { | ||
// 900 is the max number we are allowed to use in order to avoid simapp.CreateTestPubKeys | ||
// panic: encoding/hex: odd length hex string | ||
var powersNumber = 900 | ||
|
||
var totalPower int64 = 0 | ||
var powers = make([]int64, powersNumber) | ||
for i := range powers { | ||
powers[i] = int64(i) | ||
totalPower += int64(i) | ||
} | ||
|
||
app, ctx, _, valAddrs, vals := initValidators(b, totalPower, len(powers), powers) | ||
|
||
for _, validator := range vals { | ||
app.StakingKeeper.SetValidator(ctx, validator) | ||
} | ||
|
||
b.ResetTimer() | ||
for n := 0; n < b.N; n++ { | ||
for _, addr := range valAddrs { | ||
_, _ = app.StakingKeeper.GetValidator(ctx, addr) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters