Tanuj Mathur wrote:

Hi Enrico,
 Could you provide a link to the code you used to perform these
tests? i'd like to replicate the results for MSVC6, and then compare
it with MSVC 7.1 and 8 (VS 2003 and VS 2005 Beta respectively). MSVC6
is a very old compiler (1997/98), and since the C++ compiler for MSVC
2003 (7.1) is available free of cost, that would be a way better
compiler to target.

Thanks,
Tanuj

Hi Tanuj,

the code is a simple function that gets called 300000000 times.

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

int my_function (int a, char *buf)
{

  int  int_1 = 1987;
  char char_1 = 'a';
  long long_1 = 123456789L;
  long long_2 = &long_1;

  if (a > 0)
  {
      a++;
  }
  else
  {
      a--;
  }
  if (int_1 > 9)
  {
      char_1++;
  }
  else
  {
      char_1--;
  }
  *long_2++;
  if (buf == NULL)
  {
      return -1;
  }
  buf++;
  return a;
}


void main (void)
{

  long i;
  int result;
  char buf[8];
  clock_t start;
  clock_t stop;
  double  duration;

  buf[0] = 0;

  start = clock();
  for (i = 0; i < 300000000; i++)
  {
       result = my_function(10,buf);
  }
  stop = clock();
  duration = (double) (stop - start) / CLOCKS_PER_SEC;

  printf("the test lasted for %2.4f seconds\n\r",duration);
}
-------------------------------------------------------------------------

Enrico

Reply via email to