strings: add IndexByte benchmark

Like existing Index, IndexRune, IndexHardN, etc.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486044
This commit is contained in:
Brad Fitzpatrick 2013-08-06 14:41:07 -07:00
parent 12e46e42ec
commit 1104a2afb1

View file

@ -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