aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string_test.go
diff options
context:
space:
mode:
authorMartin Möhrmann <martisch@uos.de>2016-09-02 17:04:41 +0200
committerBrad Fitzpatrick <bradfitz@golang.org>2016-10-17 11:25:22 +0000
commitd2951740303587fc0c5d14cb5461e39b099e6695 (patch)
tree97625f704787b103946792ad7475235744826c91 /src/runtime/string_test.go
parentfe4307f0607dff7742d047b04df06e721aea7906 (diff)
downloadgo-d2951740303587fc0c5d14cb5461e39b099e6695.tar.gz
go-d2951740303587fc0c5d14cb5461e39b099e6695.zip
runtime: speed up non-ASCII rune decoding
Copies utf8 constants and EncodeRune implementation from unicode/utf8. Adds a new decoderune implementation that is used by the compiler in code generated for ranging over strings. It does not handle ASCII runes since these are handled directly before calls to decoderune. The DecodeRuneInString implementation from unicode/utf8 is not used since it uses a lookup table that would increase the use of cpu caches. Adds more tests that check decoding of valid and invalid utf8 sequences. name old time/op new time/op delta RuneIterate/range2/ASCII-4 7.45ns ± 2% 7.45ns ± 1% ~ (p=0.634 n=16+16) RuneIterate/range2/Japanese-4 53.5ns ± 1% 49.2ns ± 2% -8.03% (p=0.000 n=20+20) RuneIterate/range2/MixedLength-4 46.3ns ± 1% 41.0ns ± 2% -11.57% (p=0.000 n=20+20) new: "".decoderune t=1 size=423 args=0x28 locals=0x0 old: "".charntorune t=1 size=666 args=0x28 locals=0x0 Change-Id: I1df1fdb385bb9ea5e5e71b8818ea2bf5ce62de52 Reviewed-on: https://go-review.googlesource.com/28490 Run-TryBot: Martin Möhrmann <martisch@uos.de> 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.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/string_test.go b/src/runtime/string_test.go
index 4ee32ea671..ef0b01c237 100644
--- a/src/runtime/string_test.go
+++ b/src/runtime/string_test.go
@@ -92,6 +92,7 @@ func BenchmarkConcatStringAndBytes(b *testing.B) {
var stringdata = []struct{ name, data string }{
{"ASCII", "01234567890"},
{"Japanese", "日本語日本語日本語"},
+ {"MixedLength", "$Ѐࠀက퀀𐀀\U00040000\U0010FFFF"},
}
func BenchmarkRuneIterate(b *testing.B) {