tpl/strings: Adjust benchmark

This commit is contained in:
Bjørn Erik Pedersen 2023-03-01 17:59:02 +01:00
parent 079d1b6540
commit 2a61910e82
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -83,7 +83,16 @@ func TestTruncate(t *testing.T) {
} }
func BenchmarkTruncate(b *testing.B) { func BenchmarkTruncate(b *testing.B) {
b.Run("Plain text", func(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
ns.Truncate(10, "<p>test <b>hello</b> test something</p>") ns.Truncate(10, "I am a test sentence")
} }
})
b.Run("With link", func(b *testing.B) {
for i := 0; i < b.N; i++ {
ns.Truncate(10, "I have a <a href='/markdown'>Markdown link</a> inside")
}
})
} }