-
Notifications
You must be signed in to change notification settings - Fork 15
/
bench_test.go
70 lines (60 loc) · 1.13 KB
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package stream_test
import (
"github.com/ghemawat/stream"
"fmt"
"os"
"testing"
)
func BenchmarkSingle(b *testing.B) {
stream.Run(stream.Repeat("", b.N))
}
func BenchmarkFive(b *testing.B) {
f := stream.FilterFunc(func(arg stream.Arg) error {
for s := range arg.In {
arg.Out <- s
}
return nil
})
stream.Run(stream.Repeat("", b.N), f, f, f, f)
}
func BenchmarkWrite(b *testing.B) {
f, err := os.Create("/dev/null")
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
stream.Run(
stream.Repeat("hello", b.N),
stream.WriteLines(f),
)
}
func BenchmarkSample(b *testing.B) {
stream.Run(
stream.Repeat("hello", b.N),
stream.Sample(10),
)
}
func BenchmarkSort(b *testing.B) {
stream.Run(
stream.Repeat("hello", b.N),
stream.Sort(),
)
}
func BenchmarkSort3(b *testing.B) {
stream.Run(
stream.Repeat("the 3 musketeers", b.N),
stream.Sort().Num(2).Text(1).Text(3),
)
}
func BenchmarkCmd(b *testing.B) {
stream.Run(
stream.Repeat("hello", b.N),
stream.Command("cat"),
)
}
func BenchmarkXargs1(b *testing.B) {
stream.Run(
stream.Repeat("hello", b.N),
stream.Xargs("true").LimitArgs(1),
)
}