From 02123df8cc15896f97c1580e49d8e2a991e37ddd Mon Sep 17 00:00:00 2001 From: sangtran Date: Thu, 3 Sep 2026 23:10:33 +0700 Subject: Moving all legacy quacker source code from github to cgit --- pipeline/pipeline_bench_test.go | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pipeline/pipeline_bench_test.go (limited to 'pipeline/pipeline_bench_test.go') diff --git a/pipeline/pipeline_bench_test.go b/pipeline/pipeline_bench_test.go new file mode 100644 index 0000000..f4f81a0 --- /dev/null +++ b/pipeline/pipeline_bench_test.go @@ -0,0 +1,55 @@ +package pipeline + +import ( + "context" + "testing" +) + +func BenchmarkMap(b *testing.B) { + b.ReportAllocs() + + input := make(chan int, 256) + + out := Run(b.Context(), input, + Map(4, func(_ context.Context, v int) (int, bool) { + return v * 2, true + }), + ) + + go func() { + for range out { + } + }() + + for b.Loop() { + input <- 1 + } + + close(input) +} + +func BenchmarkPipeline_Composition(b *testing.B) { + b.ReportAllocs() + + input := make(chan int, 256) + + out := Run(b.Context(), input, + Filter(func(v int) bool { return v > 0 }), + Map(4, func(_ context.Context, v int) (int, bool) { + return v * 2, true + }), + Buffer[int](64), + Sink(2, func(_ context.Context, v int) {}), + ) + + go func() { + for range out { + } + }() + + for b.Loop() { + input <- 1 + } + + close(input) +} -- cgit v1.3.1