Standard library / runtime

runtime.SetBlockProfileRate()

Configure time-based blocking-event sampling. Rate 1 records all blocking events; nonpositive disables it. This example exercises configuration, not sample attribution. Expected stdout: 'configured\n'.

Formal Syntax & Structure

go syntaxgo
func SetBlockProfileRate(rate int)

Parameters & Attributes

NameTypeDescription
rateintAverage nanoseconds blocked per sample; 1 records every event, nonpositive disables.

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() {  runtime.SetBlockProfileRate(1)  runtime.SetBlockProfileRate(0)  fmt.Println("configured")}
Go Reference