Commit 32c76db4 authored by protolambda's avatar protolambda

cmd: make pprof optional

parent 1741146c
...@@ -76,6 +76,10 @@ var ( ...@@ -76,6 +76,10 @@ var (
Value: MustStepMatcherFlag("%100000"), Value: MustStepMatcherFlag("%100000"),
Required: false, Required: false,
} }
RunPProfCPU = &cli.BoolFlag{
Name: "pprof.cpu",
Usage: "enable pprof cpu profiling",
}
) )
type Proof struct { type Proof struct {
...@@ -192,7 +196,9 @@ func Guard(proc *os.ProcessState, fn StepFn) StepFn { ...@@ -192,7 +196,9 @@ func Guard(proc *os.ProcessState, fn StepFn) StepFn {
var _ mipsevm.PreimageOracle = (*ProcessPreimageOracle)(nil) var _ mipsevm.PreimageOracle = (*ProcessPreimageOracle)(nil)
func Run(ctx *cli.Context) error { func Run(ctx *cli.Context) error {
if ctx.Bool(RunPProfCPU.Name) {
defer profile.Start(profile.NoShutdownHook, profile.ProfilePath("."), profile.CPUProfile).Stop() defer profile.Start(profile.NoShutdownHook, profile.ProfilePath("."), profile.CPUProfile).Stop()
}
state, err := loadJSON[mipsevm.State](ctx.Path(RunInputFlag.Name)) state, err := loadJSON[mipsevm.State](ctx.Path(RunInputFlag.Name))
if err != nil { if err != nil {
...@@ -347,5 +353,6 @@ var RunCommand = &cli.Command{ ...@@ -347,5 +353,6 @@ var RunCommand = &cli.Command{
RunStopAtFlag, RunStopAtFlag,
RunMetaFlag, RunMetaFlag,
RunInfoAtFlag, RunInfoAtFlag,
RunPProfCPU,
}, },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment