refactor: use b.Loop() to simplify the code and improve performance (#4389)

Signed-off-by: reddaisyy <reddaisy@outlook.jp>
This commit is contained in:
reddaisyy 2025-10-09 11:36:56 +08:00 committed by GitHub
parent 053e5765fd
commit 9968c4bf9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,25 +81,25 @@ func TestStringToBytes(t *testing.T) {
// go test -v -run=none -bench=^BenchmarkBytesConv -benchmem=true
func BenchmarkBytesConvBytesToStrRaw(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
rawBytesToStr(testBytes)
}
}
func BenchmarkBytesConvBytesToStr(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
BytesToString(testBytes)
}
}
func BenchmarkBytesConvStrToBytesRaw(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
rawStrToBytes(testString)
}
}
func BenchmarkBytesConvStrToBytes(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
StringToBytes(testString)
}
}