diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-14 17:11:35 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-14 17:11:35 +0000 |
commit | e104cab8d4ab9422a0ca55bb24c00c9fea9a5d4d (patch) | |
tree | 8d262a22ca7318f4bcd64269fe8fe9e45bcf8d0f /libgo/go/strings/replace_test.go | |
parent | 4a85c0b16ef3722655012f596b7e3e7e272eeb56 (diff) | |
download | gcc-e104cab8d4ab9422a0ca55bb24c00c9fea9a5d4d.tar.gz |
libgo: update to go1.9
Reviewed-on: https://go-review.googlesource.com/63753
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252767 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/strings/replace_test.go')
-rw-r--r-- | libgo/go/strings/replace_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libgo/go/strings/replace_test.go b/libgo/go/strings/replace_test.go index 77e48b988bc..34b5badfadf 100644 --- a/libgo/go/strings/replace_test.go +++ b/libgo/go/strings/replace_test.go @@ -540,3 +540,44 @@ func BenchmarkByteByteMap(b *testing.B) { Map(fn, str) } } + +var mapdata = []struct{ name, data string }{ + {"ASCII", "a b c d e f g h i j k l m n o p q r s t u v w x y z"}, + {"Greek", "α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω"}, +} + +func BenchmarkMap(b *testing.B) { + mapidentity := func(r rune) rune { + return r + } + + b.Run("identity", func(b *testing.B) { + for _, md := range mapdata { + b.Run(md.name, func(b *testing.B) { + for i := 0; i < b.N; i++ { + Map(mapidentity, md.data) + } + }) + } + }) + + mapchange := func(r rune) rune { + if 'a' <= r && r <= 'z' { + return r + 'A' - 'a' + } + if 'α' <= r && r <= 'ω' { + return r + 'Α' - 'α' + } + return r + } + + b.Run("change", func(b *testing.B) { + for _, md := range mapdata { + b.Run(md.name, func(b *testing.B) { + for i := 0; i < b.N; i++ { + Map(mapchange, md.data) + } + }) + } + }) +} |