Author: Robert Hyatt
Date: 07:33:48 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?
They are equivalent, actually, since C doesn't really have an "array" data
type. One of the things that students have trouble with is that if you use
the pointer declaration form above, you can do this:
*(large_array+i)=0;
large_array[i]=0;
even though the large_array declaration is not an array... because arrays
are implemented in C via pointers.
>
>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,...}?
Global may be faster. local will require using the stack and an extra
register possibly. If the X86 had a reasonable number of registers, this
wouldn't be a problem at all.
>
>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.