MCPcopy Create free account
hub / github.com/ReactiveX/RxGo / Benchmark_Reduce_Parallel

Function Benchmark_Reduce_Parallel

observable_operator_bench_test.go:83–102  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

81}
82
83func Benchmark_Reduce_Parallel(b *testing.B) {
84 for i := 0; i < b.N; i++ {
85 b.StopTimer()
86 obs := Range(0, benchNumberOfElementsSmall, WithBufferedChannel(benchChannelCap)).
87 Reduce(func(_ context.Context, acc, elem interface{}) (interface{}, error) {
88 // Simulate a blocking IO call
89 time.Sleep(5 * time.Millisecond)
90 if a, ok := acc.(int); ok {
91 if b, ok := elem.(int); ok {
92 return a + b, nil
93 }
94 } else {
95 return elem.(int), nil
96 }
97 return 0, errFoo
98 }, WithPool(ioPool))
99 b.StartTimer()
100 <-obs.Run()
101 }
102}
103
104func Benchmark_Map_Sequential(b *testing.B) {
105 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 5

RangeFunction · 0.85
WithBufferedChannelFunction · 0.85
WithPoolFunction · 0.85
ReduceMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…