gprof


简介

可以查看每个函数的调用时间以及调用次数等信息, 对于性能调优和分析源码很有帮助

使用方法

  1. 编译参数加上 -pg
  2. 运行程序 如 ./hello chris 会生成gmon.out文件
  3. gprof -b ./hello gmon.out |less 可以看到格式化的结果

高级