func getBenchmarkSiteDeepContent(b testing.TB) *sitesBuilder {
pageContent := func(size int) string {
- return getBenchmarkTestDataPageContentForMarkdown(size, benchmarkMarkdownSnippets)
+ return getBenchmarkTestDataPageContentForMarkdown(size, "", benchmarkMarkdownSnippets)
}
sb := newTestSitesBuilder(b).WithConfigFile("toml", `
return sb
}
-func getBenchmarkTestDataPageContentForMarkdown(size int, markdown string) string {
- return `---
+func getBenchmarkTestDataPageContentForMarkdown(size int, category, markdown string) string {
+ base := `---
title: "My Page"
+%s
---
My page content.
+`
+
+ var categoryKey string
+ if category != "" {
+ categoryKey = fmt.Sprintf("categories: [%s]", category)
+ }
+ base = fmt.Sprintf(base, categoryKey)
-` + strings.Repeat(markdown, size)
+ return base + strings.Repeat(markdown, size)
}
const benchmarkMarkdownSnippets = `
func getBenchmarkSiteNewTestCases() []siteBenchmarkTestcase {
+ pageContentWithCategory := func(size int, category string) string {
+ return getBenchmarkTestDataPageContentForMarkdown(size, category, benchmarkMarkdownSnippets)
+ }
+
pageContent := func(size int) string {
- return getBenchmarkTestDataPageContentForMarkdown(size, benchmarkMarkdownSnippets)
+ return getBenchmarkTestDataPageContentForMarkdown(size, "", benchmarkMarkdownSnippets)
}
config := `
`)
- sb.WithTemplatesAdded("index.html", pageTemplateTemplate)
- sb.WithTemplatesAdded("_default/single.html", pageTemplateTemplate)
- sb.WithTemplatesAdded("_default/list.html", pageTemplateTemplate)
+ sb.WithTemplates("index.html", pageTemplateTemplate)
+ sb.WithTemplates("_default/single.html", pageTemplateTemplate)
+ sb.WithTemplates("_default/list.html", pageTemplateTemplate)
+
+ r := rand.New(rand.NewSource(99))
createContent := func(dir, name string) {
- sb.WithContent(filepath.Join("content", dir, name), pageContent(1))
+ var content string
+ if strings.Contains(name, "_index") {
+ content = pageContent(1)
+
+ } else {
+ content = pageContentWithCategory(1, fmt.Sprintf("category%d", r.Intn(5)+1))
+ }
+
+ sb.WithContent(filepath.Join("content", dir, name), content)
}
createBundledFiles := func(dir string) {
}
}
- r := rand.New(rand.NewSource(99))
-
for _, lang := range []string{"en", "fr", "no", "sv"} {
for level := 1; level <= r.Intn(5)+1; level++ {
sectionDir := path.Join(lang, strings.Repeat("section/", level))