From e607abbfd6e0550c13f4fa7b666d033eb9b14759 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Tue, 17 Nov 2015 16:51:23 +0200 Subject: unicode: improve SimpleFold performance for ascii This change significantly speeds up case-insensitive regexp matching. benchmark old ns/op new ns/op delta BenchmarkMatchEasy0i_32-8 2690 1473 -45.24% BenchmarkMatchEasy0i_1K-8 80404 42269 -47.43% BenchmarkMatchEasy0i_32K-8 3272187 2076118 -36.55% BenchmarkMatchEasy0i_1M-8 104805990 66503805 -36.55% BenchmarkMatchEasy0i_32M-8 3360192200 2126121600 -36.73% benchmark old MB/s new MB/s speedup BenchmarkMatchEasy0i_32-8 11.90 21.72 1.83x BenchmarkMatchEasy0i_1K-8 12.74 24.23 1.90x BenchmarkMatchEasy0i_32K-8 10.01 15.78 1.58x BenchmarkMatchEasy0i_1M-8 10.00 15.77 1.58x BenchmarkMatchEasy0i_32M-8 9.99 15.78 1.58x Issue #13288 Change-Id: I94af7bb29e75d60b4f6ee760124867ab271b9642 Reviewed-on: https://go-review.googlesource.com/16943 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/regexp/exec_test.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/regexp/exec_test.go') diff --git a/src/regexp/exec_test.go b/src/regexp/exec_test.go index cfc1e147c1..f8f5f4020e 100644 --- a/src/regexp/exec_test.go +++ b/src/regexp/exec_test.go @@ -672,6 +672,7 @@ func benchmark(b *testing.B, re string, n int) { const ( easy0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ$" + easy0i = "(?i)ABCDEFGHIJklmnopqrstuvwxyz$" easy1 = "A[AB]B[BC]C[CD]D[DE]E[EF]F[FG]G[GH]H[HI]I[IJ]J$" medium = "[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$" hard = "[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$" @@ -682,6 +683,11 @@ func BenchmarkMatchEasy0_1K(b *testing.B) { benchmark(b, easy0, 1<<10) } func BenchmarkMatchEasy0_32K(b *testing.B) { benchmark(b, easy0, 32<<10) } func BenchmarkMatchEasy0_1M(b *testing.B) { benchmark(b, easy0, 1<<20) } func BenchmarkMatchEasy0_32M(b *testing.B) { benchmark(b, easy0, 32<<20) } +func BenchmarkMatchEasy0i_32(b *testing.B) { benchmark(b, easy0i, 32<<0) } +func BenchmarkMatchEasy0i_1K(b *testing.B) { benchmark(b, easy0i, 1<<10) } +func BenchmarkMatchEasy0i_32K(b *testing.B) { benchmark(b, easy0i, 32<<10) } +func BenchmarkMatchEasy0i_1M(b *testing.B) { benchmark(b, easy0i, 1<<20) } +func BenchmarkMatchEasy0i_32M(b *testing.B) { benchmark(b, easy0i, 32<<20) } func BenchmarkMatchEasy1_32(b *testing.B) { benchmark(b, easy1, 32<<0) } func BenchmarkMatchEasy1_1K(b *testing.B) { benchmark(b, easy1, 1<<10) } func BenchmarkMatchEasy1_32K(b *testing.B) { benchmark(b, easy1, 32<<10) } -- cgit v1.3 From 70d95a488da89d268d0a61171ec389982a62184d Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Tue, 26 Apr 2016 15:28:17 -0400 Subject: regexp: add a harder regexp to the benchmarks This regexp has many parallel alternations Change-Id: I8044f460aa7d18f20cb0452e9470557b87facd6d Reviewed-on: https://go-review.googlesource.com/22471 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/regexp/exec_test.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/regexp/exec_test.go') diff --git a/src/regexp/exec_test.go b/src/regexp/exec_test.go index f8f5f4020e..463fcf1848 100644 --- a/src/regexp/exec_test.go +++ b/src/regexp/exec_test.go @@ -676,6 +676,7 @@ const ( easy1 = "A[AB]B[BC]C[CD]D[DE]E[EF]F[FG]G[GH]H[HI]I[IJ]J$" medium = "[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$" hard = "[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$" + hard1 = "ABCD|CDEF|EFGH|GHIJ|IJKL|KLMN|MNOP|OPQR|QRST|STUV|UVWX|WXYZ" ) func BenchmarkMatchEasy0_32(b *testing.B) { benchmark(b, easy0, 32<<0) } @@ -703,6 +704,11 @@ func BenchmarkMatchHard_1K(b *testing.B) { benchmark(b, hard, 1<<10) } func BenchmarkMatchHard_32K(b *testing.B) { benchmark(b, hard, 32<<10) } func BenchmarkMatchHard_1M(b *testing.B) { benchmark(b, hard, 1<<20) } func BenchmarkMatchHard_32M(b *testing.B) { benchmark(b, hard, 32<<20) } +func BenchmarkMatchHard1_32(b *testing.B) { benchmark(b, hard1, 32<<0) } +func BenchmarkMatchHard1_1K(b *testing.B) { benchmark(b, hard1, 1<<10) } +func BenchmarkMatchHard1_32K(b *testing.B) { benchmark(b, hard1, 32<<10) } +func BenchmarkMatchHard1_1M(b *testing.B) { benchmark(b, hard1, 1<<20) } +func BenchmarkMatchHard1_32M(b *testing.B) { benchmark(b, hard1, 32<<20) } func TestLongest(t *testing.T) { re, err := Compile(`a(|b)`) -- cgit v1.3