Skip to content

Commit d74452c

Browse files
committed
Add benchSite.sh
And change site benchmark separator to comma to make it Bash and regexp friendly, example: ./benchSite.sh "frontmatter=YAML,num_root_sections=1,num_pages=.*,tags_per_page=20,shortcodes=false,render=false"
1 parent 978951c commit d74452c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎benchSite.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Send in a regexp mathing the benchmarks you want to run, i.e. './benchSite.sh "frontmatter=YAML"'.
4+
# Note the quotes, which will be needed for more complex expressions.
5+
# The above will run all variations, but only for front matter YAML.
6+
7+
echo "Running with BenchmarkSiteBuilding/${1}"
8+
9+
go test -run="NONE" -bench="BenchmarkSiteBuilding/${1}" -test.benchmem=true ./hugolib

‎hugolib/site_benchmark_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type siteBuildingBenchmarkConfig struct {
3333
}
3434

3535
func (s siteBuildingBenchmarkConfig) String() string {
36-
return fmt.Sprintf("frontmatter=%s|num_root_sections=%d|num_pages=%d|tags_per_page=%d|shortcodes=%t|render=%t", s.Frontmatter, s.RootSections, s.NumPages, s.TagsPerPage, s.Shortcodes, s.Render)
36+
// Make it comma separated with no spaces, so it is both Bash and regexp friendly.
37+
return fmt.Sprintf("frontmatter=%s,num_root_sections=%d,num_pages=%d,tags_per_page=%d,shortcodes=%t,render=%t", s.Frontmatter, s.RootSections, s.NumPages, s.TagsPerPage, s.Shortcodes, s.Render)
3738
}
3839

3940
func BenchmarkSiteBuilding(b *testing.B) {

0 commit comments

Comments
 (0)