StartProfiling starts profiling the CPU.
(options ProfilingOptions)
| 37 | |
| 38 | // StartProfiling starts profiling the CPU. |
| 39 | func StartProfiling(options ProfilingOptions) { |
| 40 | profMutex.Lock() |
| 41 | defer profMutex.Unlock() |
| 42 | |
| 43 | if !options.HasOptions() { |
| 44 | return |
| 45 | } |
| 46 | profOpts := []func(p *profile.Profile){profile.NoShutdownHook} |
| 47 | if options.CPU { |
| 48 | profOpts = append(profOpts, profile.CPUProfile) |
| 49 | } |
| 50 | if options.Memory { |
| 51 | profOpts = append(profOpts, profile.MemProfile) |
| 52 | } |
| 53 | if options.Block { |
| 54 | profOpts = append(profOpts, profile.BlockProfile) |
| 55 | } |
| 56 | if options.Trace { |
| 57 | profOpts = append(profOpts, profile.TraceProfile) |
| 58 | } |
| 59 | if len(options.Path) > 0 { |
| 60 | profOpts = append(profOpts, profile.ProfilePath(options.Path)) |
| 61 | } |
| 62 | prof = profile.Start(profOpts...) |
| 63 | } |
| 64 | |
| 65 | // StopProfiling stops profiling the CPU. |
| 66 | func StopProfiling() { |
no test coverage detected