File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -758,7 +758,7 @@ var cpu struct {
758
758
// not to the one used by Go. To make it work, call os/signal.Notify
759
759
// for syscall.SIGPROF, but note that doing so may break any profiling
760
760
// being done by the main program.
761
- func StartCPUProfile (w io.Writer ) error {
761
+ func StartCPUProfile (w io.Writer , specifiedRate ... int ) error {
762
762
// The runtime routines allow a variable profiling rate,
763
763
// but in practice operating systems cannot trigger signals
764
764
// at more than about 500 Hz, and our processing of the
@@ -780,7 +780,11 @@ func StartCPUProfile(w io.Writer) error {
780
780
return fmt .Errorf ("cpu profiling already in use" )
781
781
}
782
782
cpu .profiling = true
783
- runtime .SetCPUProfileRate (hz )
783
+ if len (specifiedRate ) > 0 {
784
+ runtime .SetCPUProfileRate (specifiedRate [0 ])
785
+ } else {
786
+ runtime .SetCPUProfileRate (hz )
787
+ }
784
788
go profileWriter (w )
785
789
return nil
786
790
}
You can’t perform that action at this time.
0 commit comments