FASTCALL.C
上传用户:dq031136
上传日期:2022-08-08
资源大小:802k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. #include <stdio.h>
  2. #include <time.h>
  3. int _fastcall add_fast(int a, int b)
  4.  {
  5.    return(a + b);
  6.  }
  7. int add_slow(int a, int b)
  8.  { 
  9.    return(a + b);
  10.  }
  11. void main(void)
  12.  { 
  13.    unsigned long int i, result;
  14.    clock_t start_time, stop_time;
  15.    printf("Processing...n");
  16.    start_time = clock();
  17.    for (i = 0; i < 2000000L; i++)
  18.      result = add_fast(i, -i);
  19.    stop_time = clock();
  20.    printf("Processing time for fast call %d ticksn", 
  21.      stop_time - start_time);
  22.    
  23.    start_time = clock();
  24.    for (i = 0; i < 2000000L; i++)
  25.      result = add_slow(i, -i);
  26.    stop_time = clock();
  27.    printf("Processing time for normal call %d ticksn", 
  28.      stop_time - start_time);
  29.  }