-
Notifications
You must be signed in to change notification settings - Fork 7
/
baseline_map_benchmark_test.go
99 lines (82 loc) · 1.87 KB
/
baseline_map_benchmark_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package gospeed
import "testing"
func BenchmarkBaselineNewMapLiteralIntToInt(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[int]int{}
}
}
func BenchmarkBaselineNewMapLiteralIntToInterface(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[int]any{}
}
}
func BenchmarkBaselineNewMapLiteralStringToInt(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[string]int{}
}
}
func BenchmarkBaselineNewMapLiteralStringToInterface(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[string]any{}
}
}
func BenchmarkBaselineNewMapLiteralIntToInt2Item(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[int]int{i: 0, i: 1}
}
}
func BenchmarkBaselineNewMapLiteralIntToInterface2Item(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[int]any{i: 0, i: 1}
}
}
func BenchmarkBaselineNewMapLiteralStringToInt2Item(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[string]int{"0": i, "1": i}
}
}
func BenchmarkBaselineNewMapLiteralStringToInterface2Item(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = map[string]any{"0": i, "1": i}
}
}
func BenchmarkBaselineNewMapIntToInt(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(map[int]int)
}
}
func BenchmarkBaselineNewMapIntToInterface(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(map[int]any)
}
}
func BenchmarkBaselineNewMapStringToInt(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(map[string]int)
}
}
func BenchmarkBaselineNewMapStringToInterface(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = make(map[string]any)
}
}
func BenchmarkBaselineMapIntGet(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = h[0]
}
}
func BenchmarkBaselineMapIntSet(b *testing.B) {
for i := 0; i < b.N; i++ {
h[0] = 1
}
}
func BenchmarkBaselineMapStringGet(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = hs["0"]
}
}
func BenchmarkBaselineMapStringSet(b *testing.B) {
for i := 0; i < b.N; i++ {
hs["0"] = 1
}
}