mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
Add go profiling CLI flag
This commit is contained in:
parent
51692a5825
commit
6a1d7d2fe6
1 changed files with 14 additions and 0 deletions
14
main.go
14
main.go
|
@ -5,14 +5,17 @@ import (
|
|||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/ry/v8worker2"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
var flagReload = flag.Bool("reload", false, "Reload cached remote source code.")
|
||||
var flagV8Options = flag.Bool("v8-options", false, "Print V8 command line options.")
|
||||
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
||||
|
||||
var DenoDir string
|
||||
var CompileDir string
|
||||
|
@ -53,6 +56,17 @@ func main() {
|
|||
}
|
||||
args = v8worker2.SetFlags(args)
|
||||
|
||||
// Maybe start Golang CPU profiler.
|
||||
// Use --prof for profiling JS.
|
||||
if *flagGoProf != "" {
|
||||
f, err := os.Create(*flagGoProf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
createDirs()
|
||||
createWorker()
|
||||
|
||||
|
|
Loading…
Reference in a new issue