commit c1a83076bf2c8ece8ca8bc33bd263f3614851ee4
parent 0f8dc47037f59156c04540d97ed1b588e6bc1164
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 29 May 2022 15:14:32 +0200
Add a shortcode benchmark
Diffstat:
1 file changed, 52 insertions(+), 0 deletions(-)
diff --git 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 {