Skip to content

Instantly share code, notes, and snippets.

@evanphx
Created May 2, 2015 05:21
Show Gist options
  • Save evanphx/30d077482bfeae73ee1c to your computer and use it in GitHub Desktop.
Save evanphx/30d077482bfeae73ee1c to your computer and use it in GitHub Desktop.
Go pprof broken?
package main
import (
"fmt"
"os"
"runtime/pprof"
)
func main() {
f, err := os.Create("test.pprof")
if err != nil {
panic(err)
}
defer f.Close()
err = pprof.StartCPUProfile(f)
if err != nil {
panic(err)
}
defer pprof.StopCPUProfile()
for i := 0; i < 10000000; i++ {
fmt.Sprintf("at: %d", i)
}
}
5.76s of 5.76s total ( 100%)
flat flat% sum% cum cum%
5.76s 100% 100% 5.76s 100%
(pprof) list
Total: 5.76s
(pprof) raw
PeriodType: cpu nanoseconds
Period: 10000000
Samples:
samples/count cpu/nanoseconds
2 20000000: 1 2
558 5580000000: 3 2
1 10000000: 4 5 6 7 8
1 10000000: 9 10 6 7 8
1 10000000: 11 12
3 30000000: 1 12
2 20000000: 3 12
3 30000000: 13 2
1 10000000: 14 2
3 30000000: 15 12
1 10000000: 16 12
Locations
1: 0x3a7ab
2: 0x31a90
3: 0x3a77b
4: 0x3e52e
5: 0x3ea73
6: 0x222f
7: 0x14a62
8: 0x39d40
9: 0x3e593
10: 0x3eafa
11: 0x2429b
12: 0x31ad0
13: 0x39d8e
14: 0x19f8e
15: 0x3a64c
16: 0x242b4
Mappings
(pprof) exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment