Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speed Issues and Cygwin/MSVC

Author: Dezhi Zhao

Date: 03:17:58 04/18/00

Go up one level in this thread


On April 17, 2000 at 09:59:05, Georg v. Zimmermann wrote:

>Hi,
>
>I have no clue about some speed issues. I do not know how good most compilers
>are. For example
>
>1.)
>
>if (A == B) { result = 1; } else { result = 0; }
>
>and
>
>result = 0;
>if (A == B) { result = 1; }
>
>
>does accomplish exactly the same. But in the first way the program has to set
>result = X only once, while in the second way it has to set result = X twice
>sometimes. Do compiler detect this ? Or is there a speed difference ?
>

There does exist differrence.  If you want to handle such kind of nuance
correctly, you had better to read a CPU manual.

Suppose that for most time A != B, the second approach will be better.

If you interpret the "result" only as boolean in later code, you
may even avoid any branch test: just do it.

anti_result = A ^ B; (note that anti_result is the antonym of result)


>2.)
>
>I use integer values as flags, and use 1 = true  and 0 = false. Would I get a
>speedup if I'd use a special boolean type ?
>

no. just use int as boolean type that is the best.

A final word of warning: if you consider these stuff too much, your
code will finally downgrade to assembly one as I did:)

>3.)
>
>Do lots of global variables slow a program down ? Is access to private variables
>faster ?
>
>===
>
>Another thing: how much faster is the Microsoft C++ Compiler compared to the
>Cygnus Compiler ? Does it make a difference ?
>
>Ok, this is probably asking too much. I'm right now playing around ( its heavily
>modified by now, but structure is still the same. Only the code is practically
>unreadable for anyone but me now :-( ) with this great program here:
>
>http://www.wpi.edu/~bdean/deepbug.html
>
>Since I know absolutely nothing about compilers and the libraries needed for
>linking the program the error messages I get when trying to compile the program
>under MSVC++ instead of the Cygnus compiler sound like Chinese to me.
>
>If anyone would be so kind to take a look at Bens Code and tell me how hard it
>would be to port it to make it with MSVC++ ?
>
>If it would take too long I will forget the idea, if its simple any help on
>doing that would be greatly appreciated. Remember, Compilers are a black box to
>me :-)
>
>Best regards,
>
>Georg v. Zimmermann



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.