diff --git a/.gitignore b/.gitignore index ea6ad7d..12225c5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules .vite *~ +*.prof diff --git a/cmd/extractor/extractor.go b/cmd/extractor/extractor.go index e6d4cba..7597325 100644 --- a/cmd/extractor/extractor.go +++ b/cmd/extractor/extractor.go @@ -13,6 +13,7 @@ import ( "github.com/labstack/gommon/log" "io" "os" + "runtime/pprof" "time" ) @@ -22,8 +23,21 @@ func main() { outFile := flag.String("o", "", "Output file name") skipOutput := flag.Bool("s", false, "Skip json output; show just logs") + useProfiler := flag.Bool("p", false, "Use profiler") 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" if flag.NArg() > 0 { taskFileName = flag.Arg(0)