mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: remove allocations in Split(s, "")
BenchmarkSplit1 77984460 24131380 -69.06% R=golang-dev, rsc, minux.ma, dave, extemporalgenome CC=golang-dev https://golang.org/cl/7458043
This commit is contained in:
parent
64eec93225
commit
4f43201e51
2 changed files with 23 additions and 1 deletions
|
|
@ -1095,3 +1095,21 @@ func BenchmarkFieldsFunc(b *testing.B) {
|
|||
FieldsFunc(fieldsInput, unicode.IsSpace)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSplit1(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Split(benchInputHard, "")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSplit2(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Split(benchInputHard, "/")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSplit3(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Split(benchInputHard, "hello")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue