Author: Gerd Isenberg
Date: 07:17:31 07/08/03
Go up one level in this thread
2 bits
Andrew n = 467580016, time = 4.375
Tim n = 467580016, time = 3.671
Heiner n = 467580016, time = 3.375
switch n = 467580016, time = 3.141
1 bit
Andrew n = 450000731, time = 3.765
Tim n = 450000731, time = 3.172
Heiner n = 450000731, time = 2.719 !!
switch n = 450000731, time = 2.750
lets see whether Reinhard's code will do even better...
Gerd
void heiner_func ()
{
int i;
clock_t start, stop;
srand(0);
n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
start = clock();
for (i = 0 ; i < MAX_ITERATIONS; i++)
{
unsigned long bits = randbits();
switch( smallestpower[bits] ) {
case 0: func0(); if (! (bits -= (1<<0))) goto rdy;
if (bits & (1<<1)) {
case 1: func1(); if (! (bits -= (1<<1))) goto rdy;
}
if (bits & 0x0c) {
if (bits & (1<<2)) {
case 2: func2(); if (! (bits -= (1<<2))) goto rdy;
}
if (bits & (1<<3)) {
case 3: func3(); if (! (bits -= (1<<3))) goto rdy;
}
}
if (bits & 0xf0) {
if (bits & 0x30) {
if (bits & (1<<4)) {
case 4: func4(); if (! (bits -= (1<<4))) goto rdy;
}
if (bits & (1<<5)) {
case 5: func5(); if (! (bits -= (1<<5))) goto rdy;
}
}
if (bits & 0xc0) {
if (bits & (1<<6)) {
case 6: func6();
}
if (bits & (1<<7)) {
case 7: func7();
}
}
}
}
rdy:;
}
stop = clock();
n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
printf("Heiner n = %u, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}
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.