-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_test.go
More file actions
86 lines (74 loc) · 1.67 KB
/
benchmark_test.go
File metadata and controls
86 lines (74 loc) · 1.67 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package set
import (
"slices"
"testing"
)
// b.Loop is used but there may be some drawbacks:
//
// https://github.com/golang/go/issues/73137
func BenchmarkFromSlice(b *testing.B) {
for b.Loop() {
FromSlice("a2", "a3", "a2", "a7")
}
}
func BenchmarkAddRemove(b *testing.B) {
s := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s.Add("a3", "a4")
s.Remove("a5", "a6")
}
}
func BenchmarkRemove(b *testing.B) {
s := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s.Remove("a2")
}
}
func BenchmarkCreation(b *testing.B) {
s := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s.List()
}
}
func BenchmarkIntersection(b *testing.B) {
s1 := FromSlice("a1", "a2", "a2", "a4", "a5")
s2 := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s1.Intersection(s2)
}
}
func BenchmarkIntersectionIter(b *testing.B) {
s1 := FromSlice("a1", "a2", "a2", "a4", "a5")
s2 := slices.Values([]string{"a2", "a3", "a2", "a7"})
for b.Loop() {
s1.IntersectionIter(s2)
}
}
func BenchmarkUnion(b *testing.B) {
s1 := FromSlice([]string{"a1", "a2", "a2", "a4", "a5"}...)
s2 := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s1.Union(s2)
}
}
func BenchmarkUnionIter(b *testing.B) {
s1 := FromSlice("a1", "a2", "a2", "a4", "a5")
s2 := slices.Values([]string{"a2", "a3", "a2", "a7"})
for b.Loop() {
s1.UnionIter(s2)
}
}
func BenchmarkDifference(b *testing.B) {
s1 := FromSlice("a1", "a2", "a2", "a4", "a5")
s2 := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s1.Difference(s2)
}
}
func BenchmarkSymmetricDifferenceString(b *testing.B) {
s1 := FromSlice("a1", "a2", "a2", "a4", "a5")
s2 := FromSlice("a2", "a3", "a2", "a7")
for b.Loop() {
s1.SymmetricDifference(s2)
}
}