mirror of
https://github.com/golang/go
synced 2024-11-19 22:14:43 -07:00
strings: better benchmark names; add BenchmarkIndex
R=dsymonds CC=golang-dev https://golang.org/cl/4264052
This commit is contained in:
parent
145108ed36
commit
64f75f1034
@ -138,24 +138,36 @@ func TestIndexRune(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const benchmarkString = "some_text=some☺value"
|
||||||
|
|
||||||
func BenchmarkIndexRune(b *testing.B) {
|
func BenchmarkIndexRune(b *testing.B) {
|
||||||
if got := IndexRune("some_text=some☺value", '☺'); got != 14 {
|
if got := IndexRune(benchmarkString, '☺'); got != 14 {
|
||||||
panic("wrong index: got=" + strconv.Itoa(got))
|
panic("wrong index: got=" + strconv.Itoa(got))
|
||||||
}
|
}
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
IndexRune("some_text=some☺value", '☺')
|
IndexRune(benchmarkString, '☺')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkIndexByte(b *testing.B) {
|
func BenchmarkIndexRuneFastPath(b *testing.B) {
|
||||||
if got := IndexRune("some_text=some☺value", 'v'); got != 17 {
|
if got := IndexRune(benchmarkString, 'v'); got != 17 {
|
||||||
panic("wrong index: got=" + strconv.Itoa(got))
|
panic("wrong index: got=" + strconv.Itoa(got))
|
||||||
}
|
}
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
IndexRune("some_text=some☺value", 'v')
|
IndexRune(benchmarkString, 'v')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkIndex(b *testing.B) {
|
||||||
|
if got := Index(benchmarkString, "v"); got != 17 {
|
||||||
|
panic("wrong index: got=" + strconv.Itoa(got))
|
||||||
|
}
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
Index(benchmarkString, "v")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
type ExplodeTest struct {
|
type ExplodeTest struct {
|
||||||
s string
|
s string
|
||||||
n int
|
n int
|
||||||
|
Loading…
Reference in New Issue
Block a user