Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-29 16:14:32 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-29 16:21:08 +0300
commitc1a83076bf2c8ece8ca8bc33bd263f3614851ee4 (patch)
tree3aa22d70a42c2e1b95d643d4e9c90f929734d215 /hugolib
parent0f8dc47037f59156c04540d97ed1b588e6bc1164 (diff)
Add a shortcode benchmark
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/shortcode_test.go52
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 {