aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string_test.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-03-04 16:28:59 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2017-03-05 05:14:08 +0000
commitd4451362c0fa47b25fc2e69129e68cbbee4a6bdf (patch)
tree3f4c874c376fe34a5aa9e97ef45d77aa53bb5d13 /src/runtime/string_test.go
parent57e038615d945b610f4b62c40ddeb1fd40130649 (diff)
downloadgo-d4451362c0fa47b25fc2e69129e68cbbee4a6bdf.tar.gz
go-d4451362c0fa47b25fc2e69129e68cbbee4a6bdf.zip
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: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/string_test.go')
-rw-r--r--src/runtime/string_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/runtime/string_test.go b/src/runtime/string_test.go
index fcfc52291f..7633cfde04 100644
--- a/src/runtime/string_test.go
+++ b/src/runtime/string_test.go
@@ -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", "日本語日本語日本語"},