gcc 中参数-ftest-coverage -fprofile-arcs 使用
来源:互联网 发布:麒麟与ubuntu的区别 编辑:程序博客网 时间:2024/06/11 15:05
利用gcov检测覆盖率
例子:
#include <stdio.h>
int _abs(int a)
{
if (a < 0) {
a = 0-a;
}
return a;
}
int _max(int a, int b)
{
int max = a;
if (a < b) {
max = b;
}
return max;
}
void sort( int list[], int size)
{
int i, j, temp, swap = 1;
while (swap) {
swap = 0;
for ( i = (size-1) ; i >= 0 ; i-- ) {
for ( j = 1 ; j <= i ; j++ ) {
if ( list[j-1] > list[j] ) {
temp = list[j-1];
list[j-1] = list[j];
list[j] = temp;
swap = 1;
}
}
}
}
}
int main()
{
int x = 4;
int a = 15,b = 20;
int theList[10]={10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
int i;
sort( theList, 10 );
for (i = 0 ; i < 10 ; i++) {
printf("%d\n", theList[i]);
}
printf("Hello Ubuntu!!\n");
printf("abs(%d) is %d\n",x,_abs(x));
printf("max(%d,%d) is %d\n",a,b,_max(a,b));
return 0;
}
编译
gcc -fprofile-arcs -ftest-coverage Hello.c
运行:
./a
1
2
3
4
5
6
7
8
9
10
Hello Ubuntu!!
abs(4) is 4
max(15,20) is 20
$ gcov -b Hello.c
File 'Hello.c'
Lines executed:96.88% of 32
Branches executed:100.00% of 14
Taken at least once:85.71% of 14
Calls executed:100.00% of 7
Creating 'Hello.c.gcov'
$ gcov Hello.c
File 'Hello.c'
Lines executed:96.88% of 32
Creating 'Hello.c.gcov'
以上是执行的效果,自己作为以后查看备份在这里。
- gcc 中参数-ftest-coverage -fprofile-arcs 使用
- gcc 参数 -fprofile-arcs -ftest-coverage作用
- gcc 参数 -fprofile-arcs -ftest-coverage作用
- fprofile-arcs ftest-coverage
- GCC Coverage代码分析-从GCC源码中抽取gcov/gcov-dump程序
- gcc 参数使用实例
- gcc使用参数详解
- gcc coverage test tool: gcov
- Linux系统中使用GCC CPU参数优化代码编译
- gcc 使用中常用的参数及命令
- gcc 使用中常用的参数及命令
- VCS中使用coverage metrics进行代码覆盖分析
- Jenkins中使用checkstyle, coverage, pmd, findbugs plugin
- LLVM中code coverage检测工具llvm-cov的使用
- Makefile 中 gcc 参数小结
- C++ code coverage profiling with GCC/GCOV
- gcc中使用uuidof
- GCC中使用SIMD
- Hibernate格式化sql语句实体类 BasicFormatterImpl 源码
- Android 短信收件人自动匹配与用户输入的显示不一致
- Vim简明教程
- hdoj 1518 Square 【dfs】
- Permutations
- gcc 中参数-ftest-coverage -fprofile-arcs 使用
- Android SMS 从备份恢复后,会把手机原有信息删除掉
- iPhone文件读写系统操作
- 【note】stm32 keilMDK出现warning: function XX declared implicitly
- Console程序中取得窗口句柄
- php的memcached扩展
- 大中型网站使用图片域名的必要性原因(firebug Blocking)
- JavaScript AMD规范简介(一)
- jni