aboutsummaryrefslogtreecommitdiff
path: root/src/bytes
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2019-03-15 11:29:03 +0100
committerTobias Klauser <tobias.klauser@gmail.com>2019-03-15 14:04:37 +0000
commit9d9d4eeb87ed5dae09e26d744ea7d6caf9b182dc (patch)
tree11ae71cfc1d33c56eb93d7510fedcef2a2a847a4 /src/bytes
parent694012aa3b74d0c382c13737ba65b8d80b0f9d25 (diff)
downloadgo-9d9d4eeb87ed5dae09e26d744ea7d6caf9b182dc.tar.gz
go-9d9d4eeb87ed5dae09e26d744ea7d6caf9b182dc.zip
bytes: add hard benchmarks for Index and Count
Add Benchmark(Index|Count)Hard[1-3] in preparation for implementing Index and Count in assembly on arm. Updates #29001 Change-Id: I2a9701892190e8d91de069c2f5a7f5bd3544c6c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/167798 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/bytes')
-rw-r--r--src/bytes/bytes_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go
index 98ba95009d..d508fc9895 100644
--- a/src/bytes/bytes_test.go
+++ b/src/bytes/bytes_test.go
@@ -1654,16 +1654,39 @@ func makeBenchInputHard() []byte {
var benchInputHard = makeBenchInputHard()
+func benchmarkIndexHard(b *testing.B, sep []byte) {
+ for i := 0; i < b.N; i++ {
+ Index(benchInputHard, sep)
+ }
+}
+
func benchmarkLastIndexHard(b *testing.B, sep []byte) {
for i := 0; i < b.N; i++ {
LastIndex(benchInputHard, sep)
}
}
+func benchmarkCountHard(b *testing.B, sep []byte) {
+ for i := 0; i < b.N; i++ {
+ Count(benchInputHard, sep)
+ }
+}
+
+func BenchmarkIndexHard1(b *testing.B) { benchmarkIndexHard(b, []byte("<>")) }
+func BenchmarkIndexHard2(b *testing.B) { benchmarkIndexHard(b, []byte("</pre>")) }
+func BenchmarkIndexHard3(b *testing.B) { benchmarkIndexHard(b, []byte("<b>hello world</b>")) }
+func BenchmarkIndexHard4(b *testing.B) {
+ benchmarkIndexHard(b, []byte("<pre><b>hello</b><strong>world</strong></pre>"))
+}
+
func BenchmarkLastIndexHard1(b *testing.B) { benchmarkLastIndexHard(b, []byte("<>")) }
func BenchmarkLastIndexHard2(b *testing.B) { benchmarkLastIndexHard(b, []byte("</pre>")) }
func BenchmarkLastIndexHard3(b *testing.B) { benchmarkLastIndexHard(b, []byte("<b>hello world</b>")) }
+func BenchmarkCountHard1(b *testing.B) { benchmarkCountHard(b, []byte("<>")) }
+func BenchmarkCountHard2(b *testing.B) { benchmarkCountHard(b, []byte("</pre>")) }
+func BenchmarkCountHard3(b *testing.B) { benchmarkCountHard(b, []byte("<b>hello world</b>")) }
+
func BenchmarkSplitEmptySeparator(b *testing.B) {
for i := 0; i < b.N; i++ {
Split(benchInputHard, nil)