Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion store/cache/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func BenchmarkReset(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
for range b.Loop() {
mgr.Reset()
if len(mgr.caches) != 0 {
b.Fatal("Reset failed")
Expand Down
4 changes: 2 additions & 2 deletions store/rootmulti/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) {
require.EqualValues(b, 1, version)
b.StartTimer()

for i := 0; i < b.N; i++ {
for range b.Loop() {
target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger(), metrics.NewNoOpMetrics())
for _, key := range source.StoreKeysByName() {
target.MountStoreWithDB(key, types.StoreTypeIAVL, nil)
Expand Down Expand Up @@ -278,7 +278,7 @@ func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys ui
require.EqualValues(b, 1, version)
b.StartTimer()

for i := 0; i < b.N; i++ {
for range b.Loop() {
target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger(), metrics.NewNoOpMetrics())
for _, key := range source.StoreKeysByName() {
target.MountStoreWithDB(key, types.StoreTypeIAVL, nil)
Expand Down
10 changes: 7 additions & 3 deletions x/auth/keeper/keeper_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) {
addr := sdk.AccAddress(arr)
acc := accountKeeper.NewAccountWithAddress(ctx, addr)
accountKeeper.SetAccount(ctx, acc)
idx++
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
arr := []byte{byte((i & 0xFF0000) >> 16), byte((i & 0xFF00) >> 8), byte(i & 0xFF)}
idx := 0
for range b.Loop() {
arr := []byte{byte((idx & 0xFF0000) >> 16), byte((idx & 0xFF00) >> 8), byte(idx & 0xFF)}
accountKeeper.GetAccount(ctx, sdk.AccAddress(arr))
}
}
Expand All @@ -56,10 +58,12 @@ func BenchmarkAccountMapperSetAccount(b *testing.B) {
ctx := app.NewContext(false)

// assumes b.N < 2**24
for i := 0; b.Loop(); i++ {
i := 0
for range b.Loop() {
arr := []byte{byte((i & 0xFF0000) >> 16), byte((i & 0xFF00) >> 8), byte(i & 0xFF)}
addr := sdk.AccAddress(arr)
acc := accountKeeper.NewAccountWithAddress(ctx, addr)
accountKeeper.SetAccount(ctx, acc)
i++
}
}
Loading