11func memprofile(mempath string) {
16 f, err := os.Create(mempath)
17 xcheckf(err, "creating memory profile")
19 if err := f.Close(); err != nil {
20 log.Printf("closing memory profile: %v", err)
23 runtime.GC() // get up-to-date statistics
24 err = pprof.WriteHeapProfile(f)
25 xcheckf(err, "writing memory profile")
28func profile(cpupath, mempath string) func() {
35 f, err := os.Create(cpupath)
36 xcheckf(err, "creating CPU profile")
37 err = pprof.StartCPUProfile(f)
38 xcheckf(err, "start CPU profile")
40 pprof.StopCPUProfile()
41 if err := f.Close(); err != nil {
42 log.Printf("closing cpu profile: %v", err)
48func traceExecution(path string) func() {
49 f, err := os.Create(path)
50 xcheckf(err, "create trace file")
55 xcheckf(err, "close trace file")