测试llvm-clang编译器

来源:互联网 发布:程序员你好我是攻城狮 编辑:程序博客网 时间:2024/04/26 05:53

随便写了简单的代码

#include <stdio.h>
int main()
{
unsigned int count_num;
double i, j, k;
j = 0.99999;
for( count_num = 0; count_num < 0x10000000; count_num++ )
{
i = j * 1000l;
k = i * 0.55555;
j = i / 1000;
k = j / 1000;
}
printf("hello llvmc!\n");
return 0;
}

分别用llvm-clang 和 gcc编译 ,平台是ubuntu 10.04 32bit

llvm-clang test.c -o test_llvm

 gcc test.c -o test_gcc


root@ubuntu:/tftpboot# time ./test_llvm 
hello llvmc!

real 0m4.912s
user 0m2.908s
sys 0m0.000s
root@ubuntu:/tftpboot# time ./test_gcc
hello llvmc!

real 0m5.338s
user 0m3.104s
sys 0m0.004s 

对比发现llvm没有想象中那么快,, 是不是llvm对浮点的支持不是很好,, 还是我写的测试代码没有代表性