diff options
| author | Ilya Tocar <ilya.tocar@intel.com> | 2016-04-28 17:39:55 +0300 |
|---|---|---|
| committer | Ilya Tocar <ilya.tocar@intel.com> | 2016-09-07 10:43:13 +0000 |
| commit | 0cff219c1279cb76f042004bffcefba0a169cb67 (patch) | |
| tree | a929e6aaf14d9307523a72b278d053854676d7bb /src/strings/strings_test.go | |
| parent | 83c73a85db84a04c8e60e52cfa348fc6b675fbf7 (diff) | |
| download | go-0cff219c1279cb76f042004bffcefba0a169cb67.tar.xz | |
strings: use AVX2 for Index if available
IndexHard4-4 1.50ms ± 2% 0.71ms ± 0% -52.36% (p=0.000 n=20+19)
This also fixes a bug, that caused a string of length 16 to use
two 8-byte comparisons instead of one 16-byte. And adds a test for
cases when partial_match fails.
Change-Id: I1ee8fc4e068bb36c95c45de78f067c822c0d9df0
Reviewed-on: https://go-review.googlesource.com/22551
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/strings/strings_test.go')
| -rw-r--r-- | src/strings/strings_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go index 5fdf59c88d..cf7fde5bbd 100644 --- a/src/strings/strings_test.go +++ b/src/strings/strings_test.go @@ -86,32 +86,44 @@ var indexTests = []IndexTest{ {"32145678", "01234567", -1}, {"01234567", "01234567", 0}, {"x01234567", "01234567", 1}, + {"x0123456x01234567", "01234567", 9}, {"xx01234567"[:9], "01234567", -1}, {"", "0123456789", -1}, {"3214567844", "0123456789", -1}, {"0123456789", "0123456789", 0}, {"x0123456789", "0123456789", 1}, + {"x012345678x0123456789", "0123456789", 11}, {"xyz0123456789"[:12], "0123456789", -1}, {"x01234567x89", "0123456789", -1}, {"", "0123456789012345", -1}, {"3214567889012345", "0123456789012345", -1}, {"0123456789012345", "0123456789012345", 0}, {"x0123456789012345", "0123456789012345", 1}, + {"x012345678901234x0123456789012345", "0123456789012345", 17}, {"", "01234567890123456789", -1}, {"32145678890123456789", "01234567890123456789", -1}, {"01234567890123456789", "01234567890123456789", 0}, {"x01234567890123456789", "01234567890123456789", 1}, + {"x0123456789012345678x01234567890123456789", "01234567890123456789", 21}, {"xyz01234567890123456789"[:22], "01234567890123456789", -1}, {"", "0123456789012345678901234567890", -1}, {"321456788901234567890123456789012345678911", "0123456789012345678901234567890", -1}, {"0123456789012345678901234567890", "0123456789012345678901234567890", 0}, {"x0123456789012345678901234567890", "0123456789012345678901234567890", 1}, + {"x012345678901234567890123456789x0123456789012345678901234567890", "0123456789012345678901234567890", 32}, {"xyz0123456789012345678901234567890"[:33], "0123456789012345678901234567890", -1}, {"", "01234567890123456789012345678901", -1}, {"32145678890123456789012345678901234567890211", "01234567890123456789012345678901", -1}, {"01234567890123456789012345678901", "01234567890123456789012345678901", 0}, {"x01234567890123456789012345678901", "01234567890123456789012345678901", 1}, + {"x0123456789012345678901234567890x01234567890123456789012345678901", "01234567890123456789012345678901", 33}, {"xyz01234567890123456789012345678901"[:34], "01234567890123456789012345678901", -1}, + {"xxxxxx012345678901234567890123456789012345678901234567890123456789012", "012345678901234567890123456789012345678901234567890123456789012", 6}, + {"", "0123456789012345678901234567890123456789", -1}, + {"xx012345678901234567890123456789012345678901234567890123456789012", "0123456789012345678901234567890123456789", 2}, + {"xx012345678901234567890123456789012345678901234567890123456789012"[:41], "0123456789012345678901234567890123456789", -1}, + {"xx012345678901234567890123456789012345678901234567890123456789012", "0123456789012345678901234567890123456xxx", -1}, + {"xx0123456789012345678901234567890123456789012345678901234567890120123456789012345678901234567890123456xxx", "0123456789012345678901234567890123456xxx", 65}, } var lastIndexTests = []IndexTest{ @@ -1315,6 +1327,9 @@ func benchmarkCountHard(b *testing.B, sep string) { func BenchmarkIndexHard1(b *testing.B) { benchmarkIndexHard(b, "<>") } func BenchmarkIndexHard2(b *testing.B) { benchmarkIndexHard(b, "</pre>") } func BenchmarkIndexHard3(b *testing.B) { benchmarkIndexHard(b, "<b>hello world</b>") } +func BenchmarkIndexHard4(b *testing.B) { + benchmarkIndexHard(b, "<pre><b>hello</b><strong>world</strong></pre>") +} func BenchmarkLastIndexHard1(b *testing.B) { benchmarkLastIndexHard(b, "<>") } func BenchmarkLastIndexHard2(b *testing.B) { benchmarkLastIndexHard(b, "</pre>") } |
