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>2021-07-27 20:24:19 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-27 20:27:54 +0300
commit7e1305710f08d26d9214abb5410ccd675e59a6e9 (patch)
treee1e25d0bcee73a9dc1ec06d0cd80240d5762c481 /hugolib
parentefa5760db5ef39ae084bfccb5b8f756c7b117a2a (diff)
Add a TOML front matter benchmark
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/site_benchmark_new_test.go35
1 files changed, 31 insertions, 4 deletions
diff --git a/hugolib/site_benchmark_new_test.go b/hugolib/site_benchmark_new_test.go
index 228dbeb5d..ea3f223dc 100644
--- a/hugolib/site_benchmark_new_test.go
+++ b/hugolib/site_benchmark_new_test.go
@@ -35,7 +35,7 @@ type siteBenchmarkTestcase struct {
func getBenchmarkSiteDeepContent(b testing.TB) *sitesBuilder {
pageContent := func(size int) string {
- return getBenchmarkTestDataPageContentForMarkdown(size, "", benchmarkMarkdownSnippets)
+ return getBenchmarkTestDataPageContentForMarkdown(size, false, "", benchmarkMarkdownSnippets)
}
sb := newTestSitesBuilder(b).WithConfigFile("toml", `
@@ -85,7 +85,7 @@ contentDir="content/sv"
return sb
}
-func getBenchmarkTestDataPageContentForMarkdown(size int, category, markdown string) string {
+func getBenchmarkTestDataPageContentForMarkdown(size int, toml bool, category, markdown string) string {
base := `---
title: "My Page"
%s
@@ -93,10 +93,23 @@ title: "My Page"
My page content.
`
+ if toml {
+ base = `+++
+title="My Page"
+%s
++++
+
+My page content.
+`
+
+ }
var categoryKey string
if category != "" {
categoryKey = fmt.Sprintf("categories: [%s]", category)
+ if toml {
+ categoryKey = fmt.Sprintf("categories=[%s]", category)
+ }
}
base = fmt.Sprintf(base, categoryKey)
@@ -119,11 +132,11 @@ See my [About](/about/) page for details.
func getBenchmarkSiteNewTestCases() []siteBenchmarkTestcase {
pageContentWithCategory := func(size int, category string) string {
- return getBenchmarkTestDataPageContentForMarkdown(size, category, benchmarkMarkdownSnippets)
+ return getBenchmarkTestDataPageContentForMarkdown(size, false, category, benchmarkMarkdownSnippets)
}
pageContent := func(size int) string {
- return getBenchmarkTestDataPageContentForMarkdown(size, "", benchmarkMarkdownSnippets)
+ return getBenchmarkTestDataPageContentForMarkdown(size, false, "", benchmarkMarkdownSnippets)
}
config := `
@@ -218,6 +231,20 @@ canonifyURLs = true
},
},
{
+ "TOML front matter", func(b testing.TB) *sitesBuilder {
+ sb := newTestSitesBuilder(b).WithConfigFile("toml", config)
+ for i := 1; i <= 200; i++ {
+ content := getBenchmarkTestDataPageContentForMarkdown(1, true, "\"a\", \"b\", \"c\"", benchmarkMarkdownSnippets)
+ sb.WithContent(fmt.Sprintf("content/p%d.md", i), content)
+ }
+
+ return sb
+ },
+ func(s *sitesBuilder) {
+
+ },
+ },
+ {
"Many HTML templates", func(b testing.TB) *sitesBuilder {
pageTemplateTemplate := `
<!DOCTYPE html>