github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/benchmark/loop/collection/loop_go1_22_benchmark_test.go (about) 1 //go:build goexperiment.rangefunc 2 3 package collection 4 5 import ( 6 "testing" 7 8 oset "github.com/m4gshm/gollections/collection/immutable/ordered/set" 9 "github.com/m4gshm/gollections/collection/immutable/vector" 10 ) 11 12 func Benchmark_Loop_ImmutableOrderSet_All_direct(b *testing.B) { 13 c := oset.Of(values...) 14 for _, casee := range cases { 15 b.Run(casee.name, func(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 c.All(func(v int) bool { 18 casee.load(v) 19 return true 20 }) 21 } 22 }) 23 } 24 } 25 26 func Benchmark_Loop_ImmutableOrderSet_All(b *testing.B) { 27 c := oset.Of(values...) 28 for _, casee := range cases { 29 b.Run(casee.name, func(b *testing.B) { 30 for i := 0; i < b.N; i++ { 31 for v := range c.All { 32 casee.load(v) 33 } 34 } 35 }) 36 } 37 } 38 39 func Benchmark_Loop_ImmutableVector_All(b *testing.B) { 40 c := vector.Of(values...) 41 for _, casee := range cases { 42 b.Run(casee.name, func(b *testing.B) { 43 for i := 0; i < b.N; i++ { 44 for _, v := range c.All { 45 casee.load(v) 46 } 47 } 48 }) 49 } 50 }