diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-06-25 18:08:57 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-06-25 18:26:40 +0200 |
commit | 92f31ae63b62ba52f476d55266b143f49b739fbe (patch) | |
tree | d9533f73278e9da9c5b9e84244fc7917ce3fdc22 /hugolib/hugo_smoke_test.go | |
parent | fd3953c18cc198b9d8b6474173f6b5522b8d0e47 (diff) |
Add a baseline benchmark
Diffstat (limited to 'hugolib/hugo_smoke_test.go')
-rw-r--r-- | hugolib/hugo_smoke_test.go | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/hugolib/hugo_smoke_test.go b/hugolib/hugo_smoke_test.go index 46aecf9cc..241ac537d 100644 --- a/hugolib/hugo_smoke_test.go +++ b/hugolib/hugo_smoke_test.go @@ -15,6 +15,7 @@ package hugolib import ( "fmt" + "math/rand" "strings" "testing" @@ -320,3 +321,107 @@ The content. b.CreateSites().Build(BuildCfg{}) } + +func BenchmarkBaseline(b *testing.B) { + files := ` +-- config.toml -- +baseURL = "https://example.com" +defaultContentLanguage = 'en' + +[module] +[[module.mounts]] +source = 'content/en' +target = 'content/en' +lang = 'en' +[[module.mounts]] +source = 'content/nn' +target = 'content/nn' +lang = 'nn' +[[module.mounts]] +source = 'content/no' +target = 'content/no' +lang = 'no' +[[module.mounts]] +source = 'content/sv' +target = 'content/sv' +lang = 'sv' +[[module.mounts]] +source = 'layouts' +target = 'layouts' + +[languages] +[languages.en] +title = "English" +weight = 1 +[languages.nn] +title = "Nynorsk" +weight = 2 +[languages.no] +title = "Norsk" +weight = 3 +[languages.sv] +title = "Svenska" +weight = 4 +-- layouts/_default/list.html -- +{{ .Title }} +{{ .Content }} +-- layouts/_default/single.html -- +{{ .Title }} +{{ .Content }} +-- layouts/shortcodes/myshort.html -- +{{ .Inner }} +` + + contentTemplate := ` +--- +title: "Page %d" +date: "2018-01-01" +weight: %d +--- + +## Heading 1 + +Duis nisi reprehenderit nisi cupidatat cillum aliquip ea id eu esse commodo et. + +## Heading 2 + +Aliqua labore enim et sint anim amet excepteur ea dolore. + +{{< myshort >}} +Hello, World! +{{< /myshort >}} + +Aliqua labore enim et sint anim amet excepteur ea dolore. + + +` + + for _, lang := range []string{"en", "nn", "no", "sv"} { + files += fmt.Sprintf("\n-- content/%s/_index.md --\n"+contentTemplate, lang, 1, 1, 1) + for i, root := range []string{"", "foo", "bar", "baz"} { + for j, section := range []string{"posts", "posts/funny", "posts/science", "posts/politics", "posts/world", "posts/technology", "posts/world/news", "posts/world/news/europe"} { + n := i + j + 1 + files += fmt.Sprintf("\n-- content/%s/%s/%s/_index.md --\n"+contentTemplate, lang, root, section, n, n, n) + for k := 1; k < rand.Intn(30)+1; k++ { + n := n + k + files += fmt.Sprintf("\n-- content/%s/%s/%s/p%d.md --\n"+contentTemplate, lang, root, section, n, n, n) + } + } + } + } + + 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() + } +} |