You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-15 23:54:16 +02:00
Add CPU profiler section
This commit is contained in:
24
guide/cpu-utilization.go
Normal file
24
guide/cpu-utilization.go
Normal file
@ -0,0 +1,24 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pprof.StartCPUProfile(os.Stdout)
|
||||
defer pprof.StopCPUProfile()
|
||||
|
||||
go cpuHog()
|
||||
go cpuHog()
|
||||
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
func cpuHog() {
|
||||
for {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user