mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 04:08:15 +08:00
refactor: use b.Loop() to simplify the code and improve performance
Signed-off-by: reddaisyy <reddaisy@outlook.jp>
This commit is contained in:
parent
5dd833f1f2
commit
6d14ee1f05
@ -81,25 +81,25 @@ func TestStringToBytes(t *testing.T) {
|
|||||||
// go test -v -run=none -bench=^BenchmarkBytesConv -benchmem=true
|
// go test -v -run=none -bench=^BenchmarkBytesConv -benchmem=true
|
||||||
|
|
||||||
func BenchmarkBytesConvBytesToStrRaw(b *testing.B) {
|
func BenchmarkBytesConvBytesToStrRaw(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
rawBytesToStr(testBytes)
|
rawBytesToStr(testBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkBytesConvBytesToStr(b *testing.B) {
|
func BenchmarkBytesConvBytesToStr(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
BytesToString(testBytes)
|
BytesToString(testBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkBytesConvStrToBytesRaw(b *testing.B) {
|
func BenchmarkBytesConvStrToBytesRaw(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
rawStrToBytes(testString)
|
rawStrToBytes(testString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkBytesConvStrToBytes(b *testing.B) {
|
func BenchmarkBytesConvStrToBytes(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
StringToBytes(testString)
|
StringToBytes(testString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user