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"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/ry/v8worker2"
|
"github.com/ry/v8worker2"
|
||||||
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
var flagReload = flag.Bool("reload", false, "Reload cached remote source code.")
|
var flagReload = flag.Bool("reload", false, "Reload cached remote source code.")
|
||||||
var flagV8Options = flag.Bool("v8-options", false, "Print V8 command line options.")
|
var flagV8Options = flag.Bool("v8-options", false, "Print V8 command line options.")
|
||||||
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||||
|
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
||||||
|
|
||||||
var DenoDir string
|
var DenoDir string
|
||||||
var CompileDir string
|
var CompileDir string
|
||||||
|
@ -53,6 +56,17 @@ func main() {
|
||||||
}
|
}
|
||||||
args = v8worker2.SetFlags(args)
|
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()
|
createDirs()
|
||||||
createWorker()
|
createWorker()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue