Standard library / runtime
runtime.BlockProfile()
Copy sampled synchronization blocking events. Prefer runtime/pprof for routine analysis. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func BlockProfile(p []BlockProfileRecord) (n int, ok bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []BlockProfileRecord | Destination slice of profile records; if too small, allocate using the returned count and retry. |
Return Value
(n int, ok bool)
Number of required records and whether the supplied slice was large enough to copy them.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { n, _ := runtime.BlockProfile(nil) records := make([]runtime.BlockProfileRecord, n+64) n, ok := runtime.BlockProfile(records) fmt.Println(ok && n >= 0 && n <= len(records))}