mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Extract the baseline benchmark to a test
This commit is contained in:
parent
92f31ae63b
commit
d1278f696a
1 changed files with 30 additions and 14 deletions
|
@ -322,7 +322,36 @@ The content.
|
||||||
b.CreateSites().Build(BuildCfg{})
|
b.CreateSites().Build(BuildCfg{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is just a test to verify that BenchmarkBaseline is working as intended.
|
||||||
|
func TestBenchmarkBaseline(t *testing.T) {
|
||||||
|
cfg := IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
TxtarString: benchmarkBaselineFiles(),
|
||||||
|
}
|
||||||
|
b := NewIntegrationTestBuilder(cfg).Build()
|
||||||
|
|
||||||
|
b.Assert(len(b.H.Sites), qt.Equals, 4)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkBaseline(b *testing.B) {
|
func BenchmarkBaseline(b *testing.B) {
|
||||||
|
cfg := IntegrationTestConfig{
|
||||||
|
T: b,
|
||||||
|
TxtarString: benchmarkBaselineFiles(),
|
||||||
|
}
|
||||||
|
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 benchmarkBaselineFiles() string {
|
||||||
files := `
|
files := `
|
||||||
-- config.toml --
|
-- config.toml --
|
||||||
baseURL = "https://example.com"
|
baseURL = "https://example.com"
|
||||||
|
@ -410,18 +439,5 @@ Aliqua labore enim et sint anim amet excepteur ea dolore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := IntegrationTestConfig{
|
return files
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue