mirror of
https://github.com/danog/gojekyll.git
synced 2025-01-22 12:41:13 +01:00
Add benchmark subcommand
This commit is contained in:
parent
1c904d6996
commit
eafeec129b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
_site
|
||||
/gojekyll
|
||||
*.prof
|
||||
|
@ -28,12 +28,25 @@ func buildCommand(c *cli.Context, site *gojekyll.Site) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
elapsed := time.Since(commandStartTime)
|
||||
printSetting("", fmt.Sprintf("created %d files in %.2fs.", count, elapsed.Seconds()))
|
||||
return nil
|
||||
}
|
||||
|
||||
func benchmarkCommand(c *cli.Context, site *gojekyll.Site) error {
|
||||
printSetting("Generating...", "")
|
||||
for i := 0; i < 10; i++ {
|
||||
printSetting("", fmt.Sprintf("%d", i+1))
|
||||
_, err := site.Build(buildOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
// elapsed := time.Since(commandStartTime)
|
||||
// printSetting("", fmt.Sprintf("created %d files in %.2fs.", count, elapsed.Seconds()))
|
||||
}
|
||||
|
||||
func serveCommand(c *cli.Context, site *gojekyll.Site) error {
|
||||
server := gojekyll.Server{Site: site}
|
||||
return server.Run(printSetting)
|
||||
|
@ -2,8 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/pprof"
|
||||
|
||||
"github.com/osteele/gojekyll"
|
||||
"github.com/osteele/gojekyll/helpers"
|
||||
@ -76,6 +78,18 @@ func main() {
|
||||
Action: withSite(buildCommand),
|
||||
},
|
||||
{
|
||||
Name: "benchmark",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "Benchmark",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "dry-run, n",
|
||||
Usage: "Dry run",
|
||||
Destination: &buildOptions.DryRun,
|
||||
},
|
||||
},
|
||||
Action: withSite(benchmarkCommand),
|
||||
}, {
|
||||
Name: "data",
|
||||
Aliases: []string{"b"},
|
||||
Action: withSite(dataCommand),
|
||||
@ -96,5 +110,14 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
if true {
|
||||
f, err := os.Create("gojekyll.prof")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
_ = app.Run(os.Args)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user