dqenv99518 2014-06-02 13:03
浏览 17
已采纳

分析go程序

I try to profile my go library, but I am stuck with the following output:

(pprof) top10
Total: 884 samples
     884 100.0% 100.0%      884 100.0% runtime.mach_semaphore_wait
       0   0.0% 100.0%      884 100.0% System

Which is not really helpful. My library reads a zip-file and parses the enclosed XML files (xlsx). When I move the profiling functions inside the lowest part of my library (where the actual xml decoding takes place), the output is not much 'better':

(pprof) top10   
Total: 884 samples
     884 100.0% 100.0%      884 100.0% fmt.(*fmt).formatFloat
       0   0.0% 100.0%      884 100.0% runtime.schedtrace

I know that this is a very vague question, but perhaps there are some helpful hints without having to provide the whole source code?

I have taken the profiler call from the golang blog entry and call the profiler with go tool pprof main profile after building main.go.

f, err := os.Create("profile")
if err != nil {
    log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
    ... my source code here
  • 写回答

1条回答 默认 最新

  • doudinghan8319 2014-06-02 13:12
    关注

    It's a known bug that profiling doesn't work on Mac OS X. https://code.google.com/p/go/issues/detail?id=6047

    The bug is in the Mac OS X kernel, and Russ Cox has a patch, described here: http://godoc.org/code.google.com/p/rsc/cmd/pprof_mac_fix , but that comes with dire warnings about screwing up your machine. In particular, there's known problems with the patch under Mavericks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题