diff options
| author | Russ Cox <rsc@golang.org> | 2026-02-06 12:20:42 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2026-02-26 09:56:47 -0800 |
| commit | b4ef60b9cb74c24108ad02cc11531c0f144bb77d (patch) | |
| tree | c5e91e59bb5faf9a90738c8d43480b95a51dca8b /src | |
| parent | 20d78eca0a5cb8bb18a870e1c9dc6810c5e1ef6d (diff) | |
| download | go-b4ef60b9cb74c24108ad02cc11531c0f144bb77d.tar.xz | |
regexp: add BenchmarkFindAllTenMatches
Add a benchmark of FindAll that has matches, to complement BenchmarkFindAllNoMatches.
Change-Id: Ie910bf4913693409fde089ce6df27b13e33f2caf
Reviewed-on: https://go-review.googlesource.com/c/go/+/742800
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/regexp/all_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/regexp/all_test.go b/src/regexp/all_test.go index ead184d286..bc3278db9d 100644 --- a/src/regexp/all_test.go +++ b/src/regexp/all_test.go @@ -5,6 +5,7 @@ package regexp import ( + "bytes" "reflect" "regexp/syntax" "slices" @@ -613,6 +614,19 @@ func BenchmarkFindAllNoMatches(b *testing.B) { } } +func BenchmarkFindAllTenMatches(b *testing.B) { + re := MustCompile("a+b+") + s := bytes.Repeat([]byte("acddeeabbax"), 10) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + all := re.FindAll(s, -1) + if len(all) != 10 { + b.Fatalf("FindAll(%q) = %q; want 10 matches", s, all) + } + } +} + func BenchmarkFindString(b *testing.B) { b.StopTimer() re := MustCompile("a+b+") |
