github.com/jwowillo/pipe@v1.2.0/benchmark_test.go (about) 1 package pipe_test 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/jwowillo/pipe" 8 ) 9 10 // Manual test to verify concurrency. Should finish in around 1.5 seconds since 11 // the longest word has 5 characters and each character causes a 0.1 second 12 // pause and there are 3 stages. 13 func BenchmarkPipe(b *testing.B) { 14 f := pipe.StageFunc(func(x pipe.Item) pipe.Item { 15 for _ = range x.(string) { 16 time.Sleep(time.Second / 10) 17 } 18 return x 19 }) 20 p := pipe.New(f, f, f) 21 p.Receive("cat") 22 p.Receive("wolf") 23 p.Receive("mouse") 24 p.Deliver() 25 p.Deliver() 26 p.Deliver() 27 }