hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 7e1305710f08d26d9214abb5410ccd675e59a6e9
parent efa5760db5ef39ae084bfccb5b8f756c7b117a2a
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Tue, 27 Jul 2021 19:24:19 +0200

Add a TOML front matter benchmark

Diffstat:
Mhugolib/site_benchmark_new_test.go | 35+++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git 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>