mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Simplify Site benchmarks
Now running `./benchSite.sh` should give a good baseline.
This commit is contained in:
parent
ad5ef43838
commit
c3c10f2c7c
2 changed files with 44 additions and 9 deletions
|
@ -9,4 +9,4 @@ GOEXE="${GOEXE-go}"
|
||||||
|
|
||||||
echo "Running with BenchmarkSiteBuilding/${1}"
|
echo "Running with BenchmarkSiteBuilding/${1}"
|
||||||
|
|
||||||
"${GOEXE}" test -run="NONE" -bench="BenchmarkSiteBuilding/${1}$" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof
|
"${GOEXE}" test -run="NONE" -bench="BenchmarkSiteBuilding/${1}" -test.benchmem=true ./hugolib -memprofile mem.prof -cpuprofile cpu.prof
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
package hugolib
|
package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -64,20 +65,53 @@ func (s siteBuildingBenchmarkConfig) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkSiteBuilding(b *testing.B) {
|
func BenchmarkSiteBuilding(b *testing.B) {
|
||||||
|
var (
|
||||||
|
// The below represents the full matrix of benchmarks. Big!
|
||||||
|
allFrontmatters = []string{"YAML", "TOML"}
|
||||||
|
allNumRootSections = []int{1, 5}
|
||||||
|
allNumTags = []int{0, 1, 10, 20, 50, 100, 500, 1000, 5000}
|
||||||
|
allTagsPerPage = []int{0, 1, 5, 20, 50, 80}
|
||||||
|
allNumPages = []int{1, 10, 100, 500, 1000, 5000, 10000}
|
||||||
|
allDoRender = []bool{false, true}
|
||||||
|
allDoShortCodes = []bool{false, true}
|
||||||
|
)
|
||||||
|
|
||||||
|
var runDefault bool
|
||||||
|
|
||||||
|
visitor := func(a *flag.Flag) {
|
||||||
|
if a.Name == "test.bench" && len(a.Value.String()) < 40 {
|
||||||
|
// The full suite is too big, so fall back to some smaller default if no
|
||||||
|
// restriction is set.
|
||||||
|
runDefault = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flag.Visit(visitor)
|
||||||
|
|
||||||
|
if runDefault {
|
||||||
|
allFrontmatters = allFrontmatters[1:]
|
||||||
|
allNumRootSections = allNumRootSections[0:2]
|
||||||
|
allNumTags = allNumTags[0:2]
|
||||||
|
allTagsPerPage = allTagsPerPage[2:3]
|
||||||
|
allNumPages = allNumPages[2:5]
|
||||||
|
allDoRender = allDoRender[1:2]
|
||||||
|
allDoShortCodes = allDoShortCodes[1:2]
|
||||||
|
}
|
||||||
|
|
||||||
var conf siteBuildingBenchmarkConfig
|
var conf siteBuildingBenchmarkConfig
|
||||||
for _, frontmatter := range []string{"YAML", "TOML"} {
|
for _, frontmatter := range allFrontmatters {
|
||||||
conf.Frontmatter = frontmatter
|
conf.Frontmatter = frontmatter
|
||||||
for _, rootSections := range []int{1, 5} {
|
for _, rootSections := range allNumRootSections {
|
||||||
conf.RootSections = rootSections
|
conf.RootSections = rootSections
|
||||||
for _, numTags := range []int{0, 1, 10, 20, 50, 100, 500, 1000, 5000} {
|
for _, numTags := range allNumTags {
|
||||||
conf.NumTags = numTags
|
conf.NumTags = numTags
|
||||||
for _, tagsPerPage := range []int{0, 1, 5, 20, 50, 80} {
|
for _, tagsPerPage := range allTagsPerPage {
|
||||||
conf.TagsPerPage = tagsPerPage
|
conf.TagsPerPage = tagsPerPage
|
||||||
for _, numPages := range []int{1, 10, 100, 500, 1000, 5000, 10000} {
|
for _, numPages := range allNumPages {
|
||||||
conf.NumPages = numPages
|
conf.NumPages = numPages
|
||||||
for _, render := range []bool{false, true} {
|
for _, render := range allDoRender {
|
||||||
conf.Render = render
|
conf.Render = render
|
||||||
for _, shortcodes := range []bool{false, true} {
|
for _, shortcodes := range allDoShortCodes {
|
||||||
conf.Shortcodes = shortcodes
|
conf.Shortcodes = shortcodes
|
||||||
doBenchMarkSiteBuilding(conf, b)
|
doBenchMarkSiteBuilding(conf, b)
|
||||||
}
|
}
|
||||||
|
@ -207,8 +241,9 @@ category = "categories"
|
||||||
// Maybe consider reusing the Source fs
|
// Maybe consider reusing the Source fs
|
||||||
mf := afero.NewMemMapFs()
|
mf := afero.NewMemMapFs()
|
||||||
th, h := newTestSitesFromConfig(b, mf, siteConfig,
|
th, h := newTestSitesFromConfig(b, mf, siteConfig,
|
||||||
"layouts/_default/single.html", `Single HTML|{{ .Title }}|{{ .Content }}`,
|
"layouts/_default/single.html", `Single HTML|{{ .Title }}|{{ .Content }}|{{ partial "myPartial" . }} `,
|
||||||
"layouts/_default/list.html", `List HTML|{{ .Title }}|{{ .Content }}`,
|
"layouts/_default/list.html", `List HTML|{{ .Title }}|{{ .Content }}`,
|
||||||
|
"layouts/partials/myPartial.html", `Partial: {{ "Hello **world**!" | markdownify }}`,
|
||||||
"layouts/shortcodes/myShortcode.html", `<p>MyShortcode</p>`)
|
"layouts/shortcodes/myShortcode.html", `<p>MyShortcode</p>`)
|
||||||
|
|
||||||
fs := th.Fs
|
fs := th.Fs
|
||||||
|
|
Loading…
Reference in a new issue