Commit d4451362 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

runtime: add slicebytetostring benchmark

Change-Id: I666d2c6ea8d0b54a71260809d1a2573b122865b2
Reviewed-on: https://go-review.googlesource.com/37790
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 57e03861
......@@ -6,6 +6,7 @@ package runtime_test
import (
"runtime"
"strconv"
"strings"
"testing"
)
......@@ -89,6 +90,20 @@ func BenchmarkConcatStringAndBytes(b *testing.B) {
}
}
var escapeString string
func BenchmarkSliceByteToString(b *testing.B) {
buf := []byte{'!'}
for n := 0; n < 8; n++ {
b.Run(strconv.Itoa(len(buf)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
escapeString = string(buf)
}
})
buf = append(buf, buf...)
}
}
var stringdata = []struct{ name, data string }{
{"ASCII", "01234567890"},
{"Japanese", "日本語日本語日本語"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment