From: Brad Fitzpatrick Date: Tue, 6 Aug 2013 21:41:07 +0000 (-0700) Subject: strings: add IndexByte benchmark X-Git-Tag: go1.2rc2~752 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1104a2afb188a97a153727f7a67c243038b49749;p=gostls13.git strings: add IndexByte benchmark Like existing Index, IndexRune, IndexHardN, etc. R=golang-dev, khr CC=golang-dev https://golang.org/cl/12486044 --- diff --git a/src/pkg/strings/strings_test.go b/src/pkg/strings/strings_test.go index 68b658ca46..5ffb4e208c 100644 --- a/src/pkg/strings/strings_test.go +++ b/src/pkg/strings/strings_test.go @@ -168,6 +168,15 @@ func BenchmarkIndex(b *testing.B) { } } +func BenchmarkIndexByte(b *testing.B) { + if got := IndexByte(benchmarkString, 'v'); got != 17 { + b.Fatalf("wrong index: expected 17, got=%d", got) + } + for i := 0; i < b.N; i++ { + IndexByte(benchmarkString, 'v') + } +} + var explodetests = []struct { s string n int