refactor: use b.Loop() to simplify the code and improve performance (#25367)
Signed-off-by: withtimezone <with_timezone@outlook.com>
This commit is contained in:
parent
04a1287e92
commit
39c56716bd
@ -39,8 +39,7 @@ func benchmarkValidateGenesis(b *testing.B, n int) {
|
||||
validators = append(validators, validator)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
genesisState := types.DefaultGenesisState()
|
||||
genesisState.Validators = validators
|
||||
if err := staking.ValidateGenesis(genesisState); err != nil {
|
||||
|
||||
@ -50,8 +50,8 @@ func BenchmarkApplyAndReturnValidatorSetUpdates(b *testing.B) {
|
||||
require.NoError(b, keeper.SetLastValidatorPower(ctx, valAddrs[i], validator.ConsensusPower(sdk.DefaultPowerReduction)))
|
||||
}
|
||||
ctx, _ = testEnv.ctx.CacheContext()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
for b.Loop() {
|
||||
_, _ = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user