diff options
Diffstat (limited to 'src/pkg/runtime/string_test.go')
| -rw-r--r-- | src/pkg/runtime/string_test.go | 24 |
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 { + } + } +} |
