I am trying to get a hang of Go Pro filer by following the example in go blog . I am not sure what I am doing wrong. But my profiled generated output shows 0 samples. Its weird.
rahul@g3ck0:~/programs/go$ go tool pprof parallel cpuprofile
Welcome to pprof! For help, type 'help'.
(pprof) top5
Total: 0 samples
The following is my code :
package main
import (
"fmt"
"os/exec"
"sync"
"strings"
"runtime/pprof"
"os"
)
func exe_cmd(cmd string, wg *sync.WaitGroup) {
out, err := exec.Command(cmd).Output()
if err != nil {
fmt.Println("error occured")
fmt.Printf("%s", err)
}
fmt.Printf("%s", out)
wg.Done()
}
func main() {
f, _ := os.Create("cpuprofile")
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
cmd := "echo newline >> blah.txt"
parts := strings.Fields(cmd)
head := parts[0]
parts = parts[1:len(parts)]
out, err := exec.Command(head,parts...).Output()
if err != nil {
fmt.Println("error occured")
fmt.Printf("%s", err)
}
fmt.Printf("%s", out)
}