Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
cmd: make pprof optional
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed May 5, 2023
1 parent 1741146 commit 32c76db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ var (
Value: MustStepMatcherFlag("%100000"),
Required: false,
}
RunPProfCPU = &cli.BoolFlag{
Name: "pprof.cpu",
Usage: "enable pprof cpu profiling",
}
)

type Proof struct {
Expand Down Expand Up @@ -192,7 +196,9 @@ func Guard(proc *os.ProcessState, fn StepFn) StepFn {
var _ mipsevm.PreimageOracle = (*ProcessPreimageOracle)(nil)

func Run(ctx *cli.Context) error {
defer profile.Start(profile.NoShutdownHook, profile.ProfilePath("."), profile.CPUProfile).Stop()
if ctx.Bool(RunPProfCPU.Name) {
defer profile.Start(profile.NoShutdownHook, profile.ProfilePath("."), profile.CPUProfile).Stop()
}

state, err := loadJSON[mipsevm.State](ctx.Path(RunInputFlag.Name))
if err != nil {
Expand Down Expand Up @@ -347,5 +353,6 @@ var RunCommand = &cli.Command{
RunStopAtFlag,
RunMetaFlag,
RunInfoAtFlag,
RunPProfCPU,
},
}

0 comments on commit 32c76db

Please sign in to comment.