MCPcopy Create free account
hub / github.com/benbjohnson/immutable / BenchmarkList_Iterator

Function BenchmarkList_Iterator

immutable_test.go:429–457  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

427}
428
429func BenchmarkList_Iterator(b *testing.B) {
430 const n = 10000
431 l := NewList[int]()
432 for i := 0; i < 10000; i++ {
433 l = l.Append(i)
434 }
435 b.ReportAllocs()
436 b.ResetTimer()
437
438 b.Run("Forward", func(b *testing.B) {
439 itr := l.Iterator()
440 for i := 0; i < b.N; i++ {
441 if i%n == 0 {
442 itr.First()
443 }
444 itr.Next()
445 }
446 })
447
448 b.Run("Reverse", func(b *testing.B) {
449 itr := l.Iterator()
450 for i := 0; i < b.N; i++ {
451 if i%n == 0 {
452 itr.Last()
453 }
454 itr.Prev()
455 }
456 })
457}
458
459func BenchmarkBuiltinSlice_Append(b *testing.B) {
460 b.Run("Int", func(b *testing.B) {

Callers

nothing calls this directly

Calls 6

AppendMethod · 0.45
IteratorMethod · 0.45
FirstMethod · 0.45
NextMethod · 0.45
LastMethod · 0.45
PrevMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…