forked from alajmo/sake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug
37 lines (30 loc) · 733 Bytes
/
debug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"log"
"runtime/pprof"
"os"
_ "net/http/pprof"
"github.com/alajmo/sake/cmd"
)
func main() {
fc, err := os.Create("./benchmarks/cpu.prof")
if err != nil {
log.Fatal(err)
}
fh, err := os.Create("./benchmarks/heap.prof")
if err != nil {
log.Fatal(err)
}
fg, err := os.Create("./benchmarks/goroutine.prof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(fc)
cmd.Execute()
pprof.Lookup("heap").WriteTo(fh, 0)
pprof.Lookup("goroutine").WriteTo(fg, 0)
defer pprof.StopCPUProfile()
// go tool pprof -http="localhost:8000" ./benchmarks/cpu.prof
// go tool pprof -http="localhost:8000" ./benchmarks/heap.prof
// go tool pprof -http="localhost:8000" ./benchmarks/goroutine.prof
}