-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark2_test.go
80 lines (72 loc) · 1.76 KB
/
benchmark2_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
71
72
73
74
75
76
77
78
79
80
package data
import (
"go4ml.xyz/lazy"
"testing"
)
func bench_transform_1(interface{}) interface{} {
type S struct{ Value int }
w, _ := NewWrapper(S{})
return func(x interface{}) interface{} {
y := x.(Color).Index
for j := 0; j < 60000; j++ {
y = y * x.(Color).Index
}
return w.WrapOrFail(S{y})
}
}
func Benchmark_TableFromBigListLinear(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.List(colors_N).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)))
}
}
func Benchmark_TableFromBigGenLinear(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.Generator(func(j int) (interface{}) {
if j >= len(colors_N) {
return lazy.EoS
}
return colors_N[j]
}).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)))
}
}
func Benchmark_TableFromBigSeqLinear(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.Sequence(func(j int) (interface{}) {
if j >= len(colors_N) {
return lazy.EoS
}
return colors_N[j]
}).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)))
}
}
func Benchmark_TableFromBigListCcr(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.List(colors_N).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)), 8)
}
}
func Benchmark_TableFromBigGenCcr(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.Generator(func(j int) interface{} {
if j >= len(colors_N) {
return lazy.EoS
}
return colors_N[j]
}).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)), 8)
}
}
func Benchmark_TableFromBigSeqCcr(b *testing.B) {
var x Table
for i := 0; i < b.N; i++ {
lazy.Sequence(func(j int) (interface{}) {
if j >= len(colors_N) {
return lazy.EoS
}
return colors_N[j]
}).Map1(bench_transform_1).MustDrain(x.Sink(len(colors_N)), 8)
}
}