-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmarkfun_test.go
More file actions
72 lines (65 loc) · 1.78 KB
/
Copy pathbenchmarkfun_test.go
File metadata and controls
72 lines (65 loc) · 1.78 KB
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
package benchmarkfun_test
import "fmt"
type test struct {
s1 []string
s2 []string
want []string
}
func tests() map[string]test {
return map[string]test{
"all empty": {s1: []string{}, s2: []string{}, want: []string{}},
"distinct min": {s1: []string{"a"}, s2: []string{"b"}, want: []string{}},
"distinct max": {s1: []string{"a", "b", "c"}, s2: []string{"d", "e", "f"}, want: []string{}},
"intersection min": {s1: []string{"a"}, s2: []string{"a"}, want: []string{"a"}},
"intersection max": {s1: []string{"a", "b", "c"}, s2: []string{"a", "b", "c"}, want: []string{"a", "b", "c"}},
"intersection empty str.": {s1: []string{""}, s2: []string{""}, want: []string{""}},
"intersection s1 > s2": {s1: []string{"a", "b", "c"}, s2: []string{"b"}, want: []string{"b"}},
"intersection s1 < s2": {s1: []string{"b"}, s2: []string{"a", "b", "c"}, want: []string{"b"}},
}
}
type benchmark struct {
name string
s1 []string
s2 []string
}
func benchmarks() []benchmark {
vals := func(length int, prefix string) []string {
v := make([]string, length)
for i := 0; i < length; i++ {
v[i] = fmt.Sprintf("%s%d", prefix, i)
}
return v
}
return []benchmark{
{
name: "10, 10 no intersection",
s1: vals(10, "a"),
s2: vals(10, "b"),
},
{
name: "10, 10 full intersection",
s1: vals(10, ""),
s2: vals(10, ""),
},
{
name: "100, 100 no intersection",
s1: vals(100, "a"),
s2: vals(100, "b"),
},
{
name: "100, 100 full intersection",
s1: vals(100, ""),
s2: vals(100, ""),
},
{
name: "1000, 1000 no intersection",
s1: vals(1000, "a"),
s2: vals(1000, "b"),
},
{
name: "1000, 1000 full intersection",
s1: vals(1000, ""),
s2: vals(1000, ""),
},
}
}