Standard library / runtime
runtime.MutexProfile()
Copy sampled mutex contention records. Counts can be zero without a workload. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func MutexProfile(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.MutexProfile(nil) records := make([]runtime.BlockProfileRecord, n+64) n, ok := runtime.MutexProfile(records) fmt.Println(ok && n >= 0 && n <= len(records))}