OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime | 5 package runtime |
6 | 6 |
7 import "unsafe" | 7 import "unsafe" |
8 | 8 |
9 // Breakpoint executes a breakpoint trap. | 9 // Breakpoint executes a breakpoint trap. |
10 func Breakpoint() | 10 func Breakpoint() |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 return n | 43 return n |
44 } | 44 } |
45 | 45 |
46 // NumGoroutine returns the number of goroutines that currently exist. | 46 // NumGoroutine returns the number of goroutines that currently exist. |
47 func NumGoroutine() int { | 47 func NumGoroutine() int { |
48 return int(gcount()) | 48 return int(gcount()) |
49 } | 49 } |
50 | 50 |
51 func gcount() int32 | 51 func gcount() int32 |
52 | |
53 // CPUProfile returns the next chunk of binary CPU profiling stack trace data, | |
54 // blocking until data is available. If profiling is turned off and all the pro
file | |
55 // data accumulated while it was on has been returned, CPUProfile returns nil. | |
56 // The caller must save the returned data before calling CPUProfile again. | |
57 // | |
58 // Most clients should use the runtime/pprof package or | |
59 // the testing package's -test.cpuprofile flag instead of calling | |
60 // CPUProfile directly. | |
61 func CPUProfile() []byte | |
62 | |
63 // SetCPUProfileRate sets the CPU profiling rate to hz samples per second. | |
64 // If hz <= 0, SetCPUProfileRate turns off profiling. | |
65 // If the profiler is on, the rate cannot be changed without first turning it of
f. | |
66 // | |
67 // Most clients should use the runtime/pprof package or | |
68 // the testing package's -test.cpuprofile flag instead of calling | |
69 // SetCPUProfileRate directly. | |
70 func SetCPUProfileRate(hz int) | |
OLD | NEW |