Skip to content

Commit 11747fb

Browse files
committed
Update benchmarks to use Go 1.24 features
1 parent bf3377a commit 11747fb

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

array_bench_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func benchmarkArrayGet(b *testing.B, initialArrayCount, numberOfOps int) {
231231

232232
b.StartTimer()
233233

234-
for range b.N {
234+
for b.Loop() {
235235
for range numberOfOps {
236236
index := getRandomArrayIndex(r, array)
237237
value, _ = array.Get(index)
@@ -249,7 +249,7 @@ func benchmarkArrayInsert(b *testing.B, initialArrayCount, numberOfOps int) {
249249

250250
storage := newTestPersistentStorage(b)
251251

252-
for range b.N {
252+
for b.Loop() {
253253

254254
b.StopTimer()
255255

@@ -273,7 +273,7 @@ func benchmarkArrayRemove(b *testing.B, initialArrayCount, numberOfOps int) {
273273

274274
storage := newTestPersistentStorage(b)
275275

276-
for range b.N {
276+
for b.Loop() {
277277

278278
b.StopTimer()
279279

@@ -298,7 +298,7 @@ func benchmarkArrayRemoveAll(b *testing.B, initialArrayCount int) {
298298

299299
var storable atree.Storable
300300

301-
for range b.N {
301+
for b.Loop() {
302302

303303
b.StopTimer()
304304

@@ -324,7 +324,7 @@ func benchmarkArrayPopIterate(b *testing.B, initialArrayCount int) {
324324

325325
var storable atree.Storable
326326

327-
for range b.N {
327+
for b.Loop() {
328328

329329
b.StopTimer()
330330

@@ -355,7 +355,7 @@ func benchmarkNewArrayFromAppend(b *testing.B, initialArrayCount int) {
355355

356356
b.StartTimer()
357357

358-
for range b.N {
358+
for b.Loop() {
359359
copied, _ := atree.NewArray(storage, array.Address(), array.Type())
360360

361361
_ = array.IterateReadOnly(func(value atree.Value) (bool, error) {
@@ -381,7 +381,7 @@ func benchmarkNewArrayFromBatchData(b *testing.B, initialArrayCount int) {
381381

382382
b.StartTimer()
383383

384-
for range b.N {
384+
for b.Loop() {
385385
iter, err := array.ReadOnlyIterator()
386386
require.NoError(b, err)
387387

mapcollision_bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func BenchmarkCollisionPerDigest(b *testing.B) {
148148

149149
b.StartTimer()
150150

151-
for range b.N {
151+
for b.Loop() {
152152
for k, v := range keyValues {
153153
_, _ = m.Set(testutils.CompareValue, testutils.GetHashInput, k, v)
154154
}

storage_bench_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func benchmarkFastCommit(b *testing.B, seed int64, numberOfSlabs int) {
5454
}
5555

5656
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) {
57-
for range b.N {
57+
for b.Loop() {
5858
b.StopTimer()
5959

6060
baseStorage := testutils.NewInMemBaseStorage()
@@ -95,7 +95,7 @@ func benchmarkNondeterministicFastCommit(b *testing.B, seed int64, numberOfSlabs
9595
}
9696

9797
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) {
98-
for range b.N {
98+
for b.Loop() {
9999
b.StopTimer()
100100

101101
baseStorage := testutils.NewInMemBaseStorage()
@@ -166,7 +166,7 @@ func benchmarkRetrieve(b *testing.B, seed int64, numberOfSlabs int) {
166166
}
167167

168168
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) {
169-
for range b.N {
169+
for b.Loop() {
170170
b.StopTimer()
171171

172172
baseStorage := testutils.NewInMemBaseStorageFromMap(encodedSlabs)
@@ -213,7 +213,7 @@ func benchmarkBatchPreload(b *testing.B, seed int64, numberOfSlabs int) {
213213
}
214214

215215
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) {
216-
for range b.N {
216+
for b.Loop() {
217217
b.StopTimer()
218218

219219
baseStorage := testutils.NewInMemBaseStorageFromMap(encodedSlabs)

0 commit comments

Comments
 (0)