diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-01 17:59:02 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-01 17:59:02 +0100 |
commit | 2a61910e824ad2bb223bca65c03460e83bb841e0 (patch) | |
tree | 590bf3dbd651bb9456c6452400da5dcf6f498c4b /tpl | |
parent | 079d1b65406a3ad6d6006f7f2be253e1d675e2e0 (diff) |
tpl/strings: Adjust benchmark
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/strings/truncate_test.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tpl/strings/truncate_test.go b/tpl/strings/truncate_test.go index 95ca31162..62125e1b4 100644 --- a/tpl/strings/truncate_test.go +++ b/tpl/strings/truncate_test.go @@ -83,7 +83,16 @@ func TestTruncate(t *testing.T) { } func BenchmarkTruncate(b *testing.B) { - for i := 0; i < b.N; i++ { - ns.Truncate(10, "<p>test <b>hello</b> test something</p>") - } + b.Run("Plain text", func(b *testing.B) { + for i := 0; i < b.N; i++ { + 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") + } + }) + } |