Skip to content

Commit

Permalink
Add optional param to run benchmark without presence of flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed May 14, 2020
1 parent b793adc commit 68de6d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ you need to deploy for your website.`,
func Build() {

build.CheckBenchmarkFlag(BenchmarkFlag)
defer build.Benchmark(time.Now(), "Total build")
defer build.Benchmark(time.Now(), "Total build", true)

// Get settings from config file.
siteConfig := readers.GetSiteConfig()
Expand Down
8 changes: 7 additions & 1 deletion cmd/build/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ func CheckBenchmarkFlag(flag bool) {
}

// Benchmark records time for individual build processes.
func Benchmark(start time.Time, message string) {
func Benchmark(start time.Time, message string, alwaysRun ...bool) {

// Check variadic args (used to mimic optional parameters).
if len(alwaysRun) == 1 {
// Optionally run benchmark even if user didn't pass flag.
benchmarkFlag = alwaysRun[0]
}

elapsed := time.Since(start)

Expand Down

0 comments on commit 68de6d9

Please sign in to comment.