Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: another question of speed

Author: James Swafford

Date: 05:32:15 11/16/00

Go up one level in this thread


On November 16, 2000 at 05:38:02, martin fierz wrote:

>hi,
>
>i recently moved from borland C 5.5 to visual C 6.0 professional which resulted
>in a 10% speed increase in my checkers program - this helps answer a question i
>asked recently about 'best compilers'.
>
>i have another question about speed: i'm using large arrays for different
>things, hash-xoring, bit-counting, some arrays in the evaluation etc. i noticed
>that the final speed of my program depends on how i declare them - but the
>behavior seems rather erratic. does anybody know if there should be a difference
>between declaring globals like this:
>
>int large_array[BIG_NUMBER];
>
>or
>
>int *large_array;
>
>followed by a malloc in the initialization?


I _think_ the only difference there is where it's stored in memory.
The first case (with the array) would be allocated down with
the rest of your globals, and the malloc would go on the heap, of course.



>
>and when i'm using an array in the evaluation function, should there be a
>difference between declaring the array as either a global array, or
>alternatively declaring it in the function as static int array={1,2,3,...}?

Hmm... that's a good question!  Obviously the behavior of the two
are different.  If you declared some variable <foo> global, you
can also declare it locally and "override" the global.  I'm not sure
if there's a difference in how or where they are allocated, though.

--
James


>
>thanks for your advice
>  martin





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.