Skip to content

Commit dcb9f53

Browse files
committed
Add a benchmark of strings.HasSuffix
1 parent e551ec9 commit dcb9f53

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

benchmark_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package regexpbypass
22

33
import (
4+
"fmt"
45
rust "github.com/BurntSushi/rure-go"
56
"github.com/dlclark/regexp2"
67
"github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre"
@@ -153,3 +154,24 @@ func BenchmarkRegexpBypass(b *testing.B) {
153154

154155
}
155156
}
157+
158+
func BenchmarkStringsSuffix(b *testing.B) {
159+
160+
println("")
161+
162+
lengths := []int{10, 100, 1000, 1000000, 10000000}
163+
164+
for _, length := range lengths {
165+
166+
text := strings.Repeat("a", length)
167+
168+
b.Run(fmt.Sprintf("%d", length), func(b *testing.B) {
169+
170+
for i := 0; i < b.N; i++ {
171+
if !strings.HasSuffix(text, "a") {
172+
panic("")
173+
}
174+
}
175+
})
176+
}
177+
}

0 commit comments

Comments
 (0)