hugolib: Fix tag calculation in benchmark test - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit fdcfccedcbcec122e754f544efef8732b1928eae
DIR parent 213ea74929a30c7eb7ae9036e2bf89c89263d00a
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Fri, 2 Jun 2017 09:13:45 +0200
hugolib: Fix tag calculation in benchmark test
Diffstat:
M hugolib/site_benchmark_test.go | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
---
DIR diff --git a/hugolib/site_benchmark_test.go b/hugolib/site_benchmark_test.go
@@ -69,11 +69,11 @@ func BenchmarkSiteBuilding(b *testing.B) {
conf.Frontmatter = frontmatter
for _, rootSections := range []int{1, 5} {
conf.RootSections = rootSections
- for _, numTags := range []int{20, 50, 100, 500, 1000, 5000} {
+ for _, numTags := range []int{0, 1, 10, 20, 50, 100, 500, 1000, 5000} {
conf.NumTags = numTags
for _, tagsPerPage := range []int{0, 1, 5, 20} {
conf.TagsPerPage = tagsPerPage
- for _, numPages := range []int{10, 100, 500, 1000, 5000, 10000} {
+ for _, numPages := range []int{1, 10, 100, 500, 1000, 5000, 10000} {
conf.NumPages = numPages
for _, render := range []bool{false, true} {
conf.Render = render
@@ -169,13 +169,20 @@ defaultContentLanguage = "en"
tag = "tags"
category = "categories"
`
+
+ numTags := cfg.NumTags
+
+ if cfg.TagsPerPage > numTags {
+ numTags = cfg.TagsPerPage
+ }
+
var (
contentPagesContent [3]string
- tags = make([]string, cfg.NumTags)
+ tags = make([]string, numTags)
pageTemplate string
)
- for i := 0; i < cfg.NumTags; i++ {
+ for i := 0; i < numTags; i++ {
tags[i] = fmt.Sprintf("Hugo %d", i+1)
}
@@ -210,11 +217,16 @@ category = "categories"
for i := 0; i < cfg.RootSections; i++ {
for j := 0; j < pagesPerSection; j++ {
- tagsStart := rand.Intn(cfg.NumTags) - cfg.TagsPerPage
- if tagsStart < 0 {
- tagsStart = 0
+ var tagsSlice []string
+
+ if numTags > 0 {
+ tagsStart := rand.Intn(numTags) - cfg.TagsPerPage
+ if tagsStart < 0 {
+ tagsStart = 0
+ }
+ tagsSlice = tags[tagsStart : tagsStart+cfg.TagsPerPage]
}
- tagsSlice := tags[tagsStart : tagsStart+cfg.TagsPerPage]
+
if cfg.Frontmatter == "TOML" {
pageTemplate = pageTemplateTOML
tagsStr = "[]"