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:
withtimezone
2025-09-25 11:36:28 -04:00
committed by GitHub
parent 04a1287e92
commit 39c56716bd
2 changed files with 3 additions and 4 deletions
+1 -2
View File
@@ -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 {
+2 -2
View File
@@ -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)
}
}