Add NoProfile
josharian opened this issue · 3 comments
For programs that have both non-trivial shutdown hook plumbing and flags controlling profiling, it'd be convenient to have a NoProfile option with a no-op Stop function. I'll send a PR if you're amenable.
This sounds good to me considering that:
- @josharian is still open to send a PR, and
- @davecheney is ok with it
Some thoughts I have on this are:
-
Calling it
NoProfile
would create some stutter in the external context, where you would use it asprofile.NoProfile
. Personally I would prefer something likeprofile.Off
if this is something that we really need. -
Would you be able to provide a more thorough example of how you would use this? As far as I can see it, the current implementation already allows you to conditionally run profiles via flags or other means. I think adding this additional code might unnecessarily complicate an otherwise simple package, unless I'm missing the point. You can simply do something like:
var p interface {
Stop()
}
if condition {
p = profile.Start(/* your options */)
}
// ...
if p != nil {
p.Stop()
}
Am I misunderstanding something or is this the same use case?
Hello, is this issue still valid ?