1. 首页
  2. 主题
  3. Go问与答

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

wcpsoft · · 3856 次点击
我编写的代码: ```go func SaveCpuProfile() { f, err := os.Create(fmt.Sprintf("heap_cpu_%s.prof", time.Now().Format("2015_02_26_03_04_05"))) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() f.Close() } ``` 保存结果如 http://pan.baidu.com/s/1pJI9C6n 截图,但是pprof使用top或者web命令都是0%
更多评论
var cpuProfile *os.File /*保存CPU执行信息*/ func SaveStartCpuProfile() { f, err := os.Create(fmt.Sprintf("heap_cpu_%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

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中