-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_test.go
138 lines (129 loc) · 2.7 KB
/
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package faststrconv
import (
"strconv"
"testing"
)
////nolint
//func BenchmarkGetByte(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// GetByte("0")
// //goland:noinspection GoUnhandledErrorResult
// GetByte("255")
// }
//}
//
//// nolint
//func BenchmarkGetUint16(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// //goland:noinspection GoUnhandledErrorResult
// GetUint16("0")
// GetUint16("255")
// }
//}
//
//// nolint
//func BenchmarkGetUint16DeletingLeadingZeros(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// //goland:noinspection GoUnhandledErrorResult
// GetUint16(DeleteLeadingZeros("0000"))
// GetUint16(DeleteLeadingZeros("0000255"))
// }
//}
//
//// nolint
//func BenchmarkGetUint32(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// GetUint32("0")
// GetUint32("255")
// }
//}
//
//// nolint
//func BenchmarkStrvconv_Atoi(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// //goland:noinspection ALL,GoUnhandledErrorResult
// strconv.Atoi("0")
// strconv.Atoi("255")
// }
//}
//
//// nolint
//func BenchmarkStrvconv_AtoiDeletingLeadingZeros(b *testing.B) {
// b.ReportAllocs()
// for i := 0; i < b.N; i++ {
// //goland:noinspection ALL,GoUnhandledErrorResult
// strconv.Atoi("0000")
// strconv.Atoi("0000255")
// }
//}
func BenchmarkByte2String(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Byte2String(199)
Byte2String(0)
Byte2String(55)
}
}
func BenchmarkUint162String(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Uint162String(199)
Uint162String(0)
Uint162String(55)
Uint162String(64555)
}
}
func BenchmarkUint322String(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Uint322String(199)
Uint322String(0)
Uint322String(55)
Uint322String(64555)
}
}
func BenchmarkUint642String(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Uint642String(199)
Uint642String(0)
Uint642String(55)
Uint642String(64555)
}
}
func BenchmarkUint32And642StringWithUint64(b *testing.B) {
uint199 := uint64(199)
uint0 := uint64(0)
uint55 := uint64(55)
uint64555 := uint64(64555)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Uint32And642String(uint199)
Uint32And642String(uint0)
Uint32And642String(uint55)
Uint32And642String(uint64555)
}
}
func BenchmarkUint32And642StringWithUint32(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Uint32And642String(uint32(199))
Uint32And642String(uint32(0))
Uint32And642String(uint32(55))
Uint32And642String(uint32(64555))
}
}
func BenchmarkItoa(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
strconv.Itoa(199)
strconv.Itoa(0)
strconv.Itoa(55)
strconv.Itoa(64555)
}
}