Edit: worked when i added the the executable to the pprof call
I'm trying to profile a simple program with the profiler from https://github.com/pkg/profile: and go tool pprof.
package main
import "github.com/pkg/profile"
func main() {
defer profile.Start().Stop()
t1()
t2()
}
func t1() {
for i := 0; i < 9000000000; i++ {
x := i * 2
x += x
}
}
func t2() {
for i := 0; i < 1000000000; i++ {
x := i * 2
x += x
}
}
The examples shows a nice table with all the functions that have been called and how long time was spent in each one of them, but i'm only seeing 100% usage for a few seconds with no more information
what can i do to make it output the functions? does it have anything to do with the "cpu profiling disabled" line that is outputted when the code is done?
this is what I used to generate the output:
./test
2016/12/16 11:04:39 profile: cpu profiling enabled, /tmp/profile176930291/cpu.pprof
2016/12/16 11:04:44 profile: cpu profiling disabled, /tmp/profile176930291/cpu.pprof
martin@martin-laptop:~/work/bin$ go tool pprof -text /tmp/profile176930291/cpu.pprof
4.90s of 4.90s total ( 100%)
flat flat% sum% cum cum%
4.90s 100% 100% 4.90s 100%