Why does it take so long to compile in VCC 2003?

My team needs a Sobol quasi-random number generator - a common RNG, which is famous for its good results and speed. I found what looks like a simple C implementation on the Internet . At home, I was able to compile it almost instantly using my Linux GCC compiler.

The next day I tried this at work: if I compile Visual Studio in debug mode, it will take about 1 minute. If I were to compile it in release mode , it would take about 40 minutes.

Why?

I know that the “release” mode triggers some compiler optimization ... but how can this file actually take so long to optimize? This is mainly comments and static data. It is hardly worth optimizing.

None of these computers are particularly slow, and in any case, I know that compile times are consistent across different Windows computers. I also heard that newer versions of Visual Studio have faster compilation times, but at the moment we are stuck in Visual Studio.Net 2003. Compiling on GCC (bundled with Ubuntu 8.04) always takes microseconds.

+3
source share
3 answers

, , . . , :

unsigned int i4_xor ( unsigned int i, unsigned int j )

//****************************************************************************80
//
//  Purpose:
//
//    I4_XOR calculates the exclusive OR of two integers.
//
//  Modified:
//
//    16 February 2005
//
//  Author:
//
//   John Burkardt
//
//  Parameters:
//
//    Input, unsigned int I, J, two values whose exclusive OR is needed.
//
//    Output, unsigned int I4_XOR, the exclusive OR of I and J.
//
{
  unsigned int i2;
  unsigned int j2;
  unsigned int k;
  unsigned int l;

  k = 0;
  l = 1;

  while ( i != 0 || j != 0 )
  {
    i2 = i / 2;
    j2 = j / 2;

    if ( 
      ( ( i == 2 * i2 ) && ( j != 2 * j2 ) ) ||
      ( ( i != 2 * i2 ) && ( j == 2 * j2 ) ) )
    {
      k = k + l;
    }

    i = i2;
    j = j2;
    l = 2 * l;
  }

  return k;
}

i8_xor. .

, DailyWTF .

EDIT: , , , :

function xor i:unsigned, j:unsigned
  answer = 0
  bit_position = 1
  while i <> 0 or j <> 0
    if least significant bit of i <> least significant bit of j
      answer = answer + bit_position 
    end if
    bit_position = bit_position * 2
    i = i / 2
    j = j / 2
  end while
  return answer
end function

, - , :

bit set if i <> (i / 2) * 2
bit clear if i == (i / 2) * 2

WTFy , C XOR, "^". , :

result = i4_xor (a, b);

:

result = a ^ b; // no function call at all!

xor. ( , C), XOR .

+2

V++ 2003 /.

Edit:

, ?

+2

Visual Studio 2008 , , . , , , Microsoft .

, , Microsoft VS2003.

+1

Source: https://habr.com/ru/post/1704645/


All Articles