<分区>
Possible Duplicate:
Performance difference between gcc and g++ for C program
当我无意中注意到用 gcc 编译的程序比用 g++ 编译的程序运行得更快时,我正在检查使用循环控制变量的寄存器存储说明符的性能改进。谁能给我解释一下?
代码如下:
#include <stdio.h>
const unsigned long scope = 1000000000;
int main()
{
register unsigned long i;
for (i=0; i < scope; i++);
return 0;
}
;
gcc register.c
time ./a.out
real 0m0.466s
user 0m0.468s
sys 0m0.000s
g++ register.c
time ./a.out
real 0m0.923s
user 0m0.920s
sys 0m0.000s