use profiler
This commit is contained in:
parent
0d787c90cb
commit
b87642b5b2
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.vite
|
.vite
|
||||||
*~
|
*~
|
||||||
|
*.prof
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/labstack/gommon/log"
|
"github.com/labstack/gommon/log"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime/pprof"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +23,21 @@ func main() {
|
|||||||
|
|
||||||
outFile := flag.String("o", "", "Output file name")
|
outFile := flag.String("o", "", "Output file name")
|
||||||
skipOutput := flag.Bool("s", false, "Skip json output; show just logs")
|
skipOutput := flag.Bool("s", false, "Skip json output; show just logs")
|
||||||
|
useProfiler := flag.Bool("p", false, "Use profiler")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *useProfiler {
|
||||||
|
profFile, err := os.Create("cpu.prof")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Profile create file: %v", err)
|
||||||
|
}
|
||||||
|
defer profFile.Close()
|
||||||
|
if err := pprof.StartCPUProfile(profFile); err != nil {
|
||||||
|
log.Fatalf("Start CPU profile: %v", err)
|
||||||
|
}
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
taskFileName := "task.json"
|
taskFileName := "task.json"
|
||||||
if flag.NArg() > 0 {
|
if flag.NArg() > 0 {
|
||||||
taskFileName = flag.Arg(0)
|
taskFileName = flag.Arg(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user