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

Function BenchmarkSortedMap_Iterator

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

Source from the content-addressed store, hash-verified

2335}
2336
2337func BenchmarkSortedMap_Iterator(b *testing.B) {
2338 const n = 10000
2339 m := NewSortedMap[int, int](nil)
2340 for i := 0; i < 10000; i++ {
2341 m = m.Set(i, i)
2342 }
2343 b.ReportAllocs()
2344 b.ResetTimer()
2345
2346 b.Run("Forward", func(b *testing.B) {
2347 itr := m.Iterator()
2348 for i := 0; i < b.N; i++ {
2349 if i%n == 0 {
2350 itr.First()
2351 }
2352 itr.Next()
2353 }
2354 })
2355
2356 b.Run("Reverse", func(b *testing.B) {
2357 itr := m.Iterator()
2358 for i := 0; i < b.N; i++ {
2359 if i%n == 0 {
2360 itr.Last()
2361 }
2362 itr.Prev()
2363 }
2364 })
2365}
2366
2367func BenchmarkSortedMapBuilder_Set(b *testing.B) {
2368 b.ReportAllocs()

Callers

nothing calls this directly

Calls 6

SetMethod · 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…