From c19b373c8ab8eca47a9fd02b97d8492cc099ef10 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 23 Mar 2011 11:43:37 -0400 Subject: runtime: cpu profiling support R=r CC=golang-dev https://golang.org/cl/4306043 --- src/pkg/runtime/debug.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/pkg/runtime/debug.go') diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go index b2357db303..6370a57d80 100644 --- a/src/pkg/runtime/debug.go +++ b/src/pkg/runtime/debug.go @@ -92,4 +92,24 @@ func (r *MemProfileRecord) Stack() []uintptr { // where r.AllocBytes > 0 but r.AllocBytes == r.FreeBytes. // These are sites where memory was allocated, but it has all // been released back to the runtime. +// Most clients should use the runtime/pprof package or +// the testing package's -test.memprofile flag instead +// of calling MemProfile directly. func MemProfile(p []MemProfileRecord, inuseZero bool) (n int, ok bool) + +// CPUProfile returns the next chunk of binary CPU profiling stack trace data, +// blocking until data is available. If profiling is turned off and all the profile +// data accumulated while it was on has been returned, CPUProfile returns nil. +// The caller must save the returned data before calling CPUProfile again. +// Most clients should use the runtime/pprof package or +// the testing package's -test.cpuprofile flag instead of calling +// CPUProfile directly. +func CPUProfile() []byte + +// SetCPUProfileRate sets the CPU profiling rate to hz samples per second. +// If hz <= 0, SetCPUProfileRate turns off profiling. +// If the profiler is on, the rate cannot be changed without first turning it off. +// Most clients should use the runtime/pprof package or +// the testing package's -test.cpuprofile flag instead of calling +// SetCPUProfileRate directly. +func SetCPUProfileRate(hz int) -- cgit v1.3