关于go语言获取cpu执行情况数据分析疑问?

wcpsoft · 2015-03-01 08:29:52 · 3448 次点击

解决方案是?

#2
更多评论

var cpuProfile *os.File

/保存CPU执行信息/ func SaveStartCpuProfile() { f, err := os.Create(fmt.Sprintf("heapcpu%s.prof", time.Now().Format("2015_02_26_03_04_05"))) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) cpuProfile = f }

/保存CPU执行信息/ func SaveEndCpuProfile() { if cpuProfile != nil { pprof.StopCPUProfile() cpuProfile.Close() } }

#3