diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-29 15:14:32 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-29 15:21:08 +0200 |
commit | c1a83076bf2c8ece8ca8bc33bd263f3614851ee4 (patch) | |
tree | 3aa22d70a42c2e1b95d643d4e9c90f929734d215 /hugolib | |
parent | 0f8dc47037f59156c04540d97ed1b588e6bc1164 (diff) |
Add a shortcode benchmark
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/shortcode_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index e9af2371f..7926a8203 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -297,6 +297,58 @@ func BenchmarkReplaceShortcodeTokens(b *testing.B) { } } +func BenchmarkShortcodesInSite(b *testing.B) { + files := ` +-- config.toml -- +-- layouts/shortcodes/mark1.md -- +{{ .Inner }} +-- layouts/shortcodes/mark2.md -- +1. Item Mark2 1 +1. Item Mark2 2 + 1. Item Mark2 2-1 +1. Item Mark2 3 +-- layouts/_default/single.html -- +{{ .Content }} +` + + content := ` +--- +title: "Markdown Shortcode" +--- + +## List + +1. List 1 + {{§ mark1 §}} + 1. Item Mark1 1 + 1. Item Mark1 2 + {{§ mark2 §}} + {{§ /mark1 §}} + +` + + for i := 1; i < 100; i++ { + files += fmt.Sprintf("\n-- content/posts/p%d.md --\n"+content, i+1) + } + files = strings.ReplaceAll(files, "§", "%") + + cfg := IntegrationTestConfig{ + T: b, + TxtarString: files, + } + builders := make([]*IntegrationTestBuilder, b.N) + + for i := range builders { + builders[i] = NewIntegrationTestBuilder(cfg) + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + builders[i].Build() + } +} + func TestReplaceShortcodeTokens(t *testing.T) { t.Parallel() for i, this := range []struct { |