forked from Silverfish/proton-bridge
chore: Add trace profiling option
This commit is contained in:
@ -52,6 +52,9 @@ const (
|
|||||||
flagCPUProfile = "cpu-prof"
|
flagCPUProfile = "cpu-prof"
|
||||||
flagCPUProfileShort = "p"
|
flagCPUProfileShort = "p"
|
||||||
|
|
||||||
|
flagTraceProfile = "trace-prof"
|
||||||
|
flagTraceProfileShort = "t"
|
||||||
|
|
||||||
flagMemProfile = "mem-prof"
|
flagMemProfile = "mem-prof"
|
||||||
flagMemProfileShort = "m"
|
flagMemProfileShort = "m"
|
||||||
|
|
||||||
@ -96,6 +99,11 @@ func New() *cli.App {
|
|||||||
Aliases: []string{flagCPUProfileShort},
|
Aliases: []string{flagCPUProfileShort},
|
||||||
Usage: "Generate CPU profile",
|
Usage: "Generate CPU profile",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: flagTraceProfile,
|
||||||
|
Aliases: []string{flagTraceProfileShort},
|
||||||
|
Usage: "Generate Trace profile",
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: flagMemProfile,
|
Name: flagMemProfile,
|
||||||
Aliases: []string{flagMemProfileShort},
|
Aliases: []string{flagMemProfileShort},
|
||||||
@ -379,6 +387,11 @@ func withProfiler(c *cli.Context, fn func() error) error {
|
|||||||
defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop()
|
defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Bool(flagTraceProfile) {
|
||||||
|
logrus.Debug("Running with Trace profiling")
|
||||||
|
defer profile.Start(profile.TraceProfile, profile.ProfilePath(".")).Stop()
|
||||||
|
}
|
||||||
|
|
||||||
if c.Bool(flagMemProfile) {
|
if c.Bool(flagMemProfile) {
|
||||||
logrus.Debug("Running with memory profiling")
|
logrus.Debug("Running with memory profiling")
|
||||||
defer profile.Start(profile.MemProfile, profile.MemProfileAllocs, profile.ProfilePath(".")).Stop()
|
defer profile.Start(profile.MemProfile, profile.MemProfileAllocs, profile.ProfilePath(".")).Stop()
|
||||||
|
|||||||
Reference in New Issue
Block a user