__fastcall 约束是否有效测试


__fastcall  约束比标准快(当传递参数小于3个,32位和64位这个数值不同,64位的机器多些,还有一个条件是多次运行函数才有效果,如果运行次数少那体现不出快速约束的优势)

下面的是测试代码,我的机器测试结果差距大约在0.01毫秒,可以修改for循环的次数



#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void __fastcall  add(int *a,int *b){
int c = *a + *b;
}
int main(int argc, char *argv[]) {
    clock_t start, finish;    
   /* 测量一个事件持续的时间*/    
    int a = 10;
    int b = 20;
    start = clock();    
int j = 0;
for(;j< 1000000000;j++){
  add(&a,&b);
}
    finish = clock();    
   double duration = (double)(finish - start) / CLOCKS_PER_SEC;    
    printf( "%f seconds\n", duration );    
   
   
return 0;
}

猜你喜欢

转载自blog.csdn.net/u010792039/article/details/79820722