fgprof
fgprof copied to clipboard
The flame graph is incorrect when using go 1.23.
package main
import (
"fmt"
"github.com/felixge/fgprof"
"net/http"
"os"
"time"
)
func main() {
cpuf, err := os.Create("fgprof.out")
if err != nil {
return
}
stop := fgprof.Start(cpuf, fgprof.FormatPprof)
defer stop()
for range 30 {
networkTask()
cpuTask()
}
}
func networkTask() {
resp, err := http.Get("http://google.com")
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
}
func cpuTask() {
start := time.Now()
for time.Since(start) < 100*time.Millisecond {
for i := 0; i < 10000; i++ {
_ = i
}
}
}