zoukankan      html  css  js  c++  java
  • 学一下gconv, gprof等知识

    scons、gcc、gdb、valgrind、gcov

     

    SCons 是一个用 Python 语言编写的类似于 make 工具的程序。与 make 工具相比较,SCons 的配置文件更加简单清晰明了。

     

    gconv 覆盖率

    (1) 编译

    # gcc -fprofile-arcs -ftest-coverage -o test test.c

    # ls

    test  test.c  test.gcno

    -fprofile-arcs -ftest-coverage告诉编译器生成gcov需要的额外信息,并在目标文件中插入gcov需要的extra profiling information。因此,该命令在生成可执行文件test的同时生成test.gcno文件(gcov note文件)

    (2) 收集信息

    # ./test

    Success

    # ls

    test  test.c  test.gcda  test.gcno

    执行该程序,生成test.gcda文件(gcov data文件)

    (3) 报告

    # gcov test.c

    File 'test.c'

    Lines executed:87.50% of 8

    test.c:creating 'test.c.gcov'

    # ls

    test  test.c  test.c.gcov  test.gcda  test.gcno

    3.2 gcov的选项

    (1) -a, --all-blocks

    (2) -b, --branch-probabilities

    (3) -c, --branch-counts

    gprof 性能分析

    一般用法: gprof –b 二进制程序 gmon.out >report.txt

    有一个方法可以查看应用程序的运行时间组成,在 time 命令下面执行程序。这个命令会显示一个应用程序的实际运行时间、用户空间运行时间、内核空间运行时间。

    如 time ./program

    输出:

    real    2m30.295s

    user    0m0.000s

    sys     0m0.004s

  • 相关阅读:
    swift 一些公共的宏重新定义
    iOS中正则表达式的使用
    失败的尝试,使用继承扩展数组,以及ES6的必要性
    用travis-ci编译android版nodejs
    用es6写一个分数库
    快速平方根算法的javascript实现
    windows中vim以及cmder的使用
    nodejs的交叉(跨平台)编译(to android)
    用链表实现nodejs的内存对象管理
    给socks-proxy-agent增加认证
  • 原文地址:https://www.cnblogs.com/charlesblc/p/6489891.html
Copyright © 2011-2022 走看看