aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/string_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-06-16 23:03:03 -0700
committerKeith Randall <khr@golang.org>2014-06-16 23:03:03 -0700
commit61dca94e107170d2ff3beb13bb9fa5ce49d8d6fd (patch)
tree83dadbcc4200dbb0e014f366cf07302a25011ed3 /src/pkg/runtime/string_test.go
parentb36ed9056ff57c04c34240f2dc6b1bb59e84d0c7 (diff)
downloadgo-61dca94e107170d2ff3beb13bb9fa5ce49d8d6fd.tar.xz
runtime: implement string ops in Go
Also implement go:nosplit annotation. Not really needed for now, but we'll definitely need it for other conversions. benchmark old ns/op new ns/op delta BenchmarkRuneIterate 534 474 -11.24% BenchmarkRuneIterate2 535 470 -12.15% LGTM=bradfitz R=golang-codereviews, dave, bradfitz, minux CC=golang-codereviews https://golang.org/cl/93380044
Diffstat (limited to 'src/pkg/runtime/string_test.go')
-rw-r--r--src/pkg/runtime/string_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/pkg/runtime/string_test.go b/src/pkg/runtime/string_test.go
index df3ff06a7d..dbccc24a5b 100644
--- a/src/pkg/runtime/string_test.go
+++ b/src/pkg/runtime/string_test.go
@@ -75,3 +75,27 @@ func BenchmarkCompareStringBig(b *testing.B) {
}
b.SetBytes(int64(len(s1)))
}
+
+func BenchmarkRuneIterate(b *testing.B) {
+ bytes := make([]byte, 100)
+ for i := range bytes {
+ bytes[i] = byte('A')
+ }
+ s := string(bytes)
+ for i := 0; i < b.N; i++ {
+ for _ = range s {
+ }
+ }
+}
+
+func BenchmarkRuneIterate2(b *testing.B) {
+ bytes := make([]byte, 100)
+ for i := range bytes {
+ bytes[i] = byte('A')
+ }
+ s := string(bytes)
+ for i := 0; i < b.N; i++ {
+ for _, _ = range s {
+ }
+ }
+}