Using list
command in go tool pprof
sometimes some lines of code are missing.
There is beginning of the function:
func SlowSearch(out io.Writer) {
file, err := os.Open(filePath)
if err != nil {
panic(err)
}
fileContents, err := ioutil.ReadAll(file)
if err != nil {
panic(err)
}
r := regexp.MustCompile("@")
seenBrowsers := []string{}
uniqueBrowsers := 0
foundUsers := ""
This works normal:
go test -bench . -cpuprofile bench_cpu.pprof
go tool pprof .\hw3.test.exe .\bench_cpu.pprof
Result:
(pprof) list SlowSearch
Total: 5.12s
ROUTINE ======================== hw3.SlowSearch in C:\Egor\MyProject\learn_mail.ru\3\99_hw\common.go
0 910ms (flat, cum) 17.77% of Total
. . 18: file, err := os.Open(filePath)
. . 19: if err != nil {
. . 20: panic(err)
. . 21: }
There is only function definiton line is missed.
This works worse:
go test -bench . -benchmem -cpuprofile bench_cpu.pprof -memprofile bench_mem.pprof -memprofilerate 1
Result:
(pprof) list SlowSearch
Total: 4.40s
ROUTINE ======================== hw3.SlowSearch in C:\Egor\MyProject\learn_mail.ru\3\99_hw\common.go
0 1.67s (flat, cum) 37.95% of Total
. . 28: r := regexp.MustCompile("@")
. . 29: seenBrowsers := []string{}
. . 30: uniqueBrowsers := 0
. . 31: foundUsers := ""
Much more source lines are missed.
Golang version:
go version go1.16.3 windows/amd64
I have tried to delete all binary files and rebuild - result the same.
Commands list
, weblist
, web interface with parameter -http
give same result with same missed lines in source code.
How can I return missed lines of function?