FASTCALL.C
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Development Platform:

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.  }