Computer Chess Club Archives


Search

Terms

Messages

Subject: the winner is: Heiner

Author: Gerd Isenberg

Date: 13:46:50 07/08/03

Go up one level in this thread


... at least on athlon xp2.8+

Hi all,

The results of the "dumb" test loop about bithandling with preinitialized random
numbers. Compiled with MSVC++ 6 speed optimization, inline any suitable, code
below - test yourself:

lonesome one bit:
Simple   0x20e17a76, time = 1.772
Andrew   0x20e17a76, time = 1.773
Tim      0x20e17a76, time = 1.422
Heiner   0x20e17a76, time = 1.392
Reinhard 0x20264870, time = 1.632
switch   0x20e17a76, time = 1.392

up to two one bits:
Simple   0x226c8b78, time = 1.903
Andrew   0x226c8b78, time = 1.973
Tim      0x226c8b78, time = 1.732
Heiner   0x226c8b78, time = 1.652
Reinhard 0x21b15972, time = 2.013
switch   0x226c8b78, time = 1.773

up to three one bits:
Simple   0x23f27d79, time = 2.083
Andrew   0x23f27d79, time = 2.163
Tim      0x23f27d79, time = 1.933
Heiner   0x23f27d79, time = 1.882
Reinhard 0x23374b73, time = 2.254
switch   0x23f27d79, time = 1.973

eight random bits:
Simple   0x83001752, time = 3.174
Andrew   0x83001752, time = 3.145
Tim      0x83001752, time = 5.327
Heiner   0x83001752, time = 3.425
Reinhard 0x800898de, time = 5.578
switch   0x83001752, time = 1.593

eight random bits high one probability:
Simple   0xb78285c8, time = 2.653
Andrew   0xb78285c8, time = 2.895
Tim      0xb78285c8, time = 7.490
Heiner   0xb78285c8, time = 3.395
Reinhard 0xb48b0754, time = 8.062
switch   0xb78285c8, time = 1.902

eight one bits 0xff:
Simple   0x0642ac00, time = 0.822
Andrew   0x0642ac00, time = 1.061
Tim      0x0642ac00, time = 9.233
Heiner   0x0642ac00, time = 1.493
Reinhard 0x004ccb00, time = 9.914
switch   0x0642ac00, time = 0.721



Btw. may i adjust tab-expansion here?

//----------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define MAX_ITERATIONS 100000000


unsigned long n,n1,n2,n3,n4,n5,n6,n7,n8;


// Just some handleBittions to call
void handleBit0 () { n1 += 2;}
void handleBit1 () { n2 += 3;}
void handleBit2 () { n3 += 4;}
void handleBit3 () { n4 += 5;}
void handleBit4 () { n5 += 6;}
void handleBit5 () { n6 += 7;}
void handleBit6 () { n7 += 8;}
void handleBit7 () { n8 += 9;}

int smallestpower[256] = {
-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
};

#define NRANDS (1<<14)

unsigned long randarr[NRANDS];

void initRand()
{
	srand(0);
	for (int i = 0; i < NRANDS; ++i)
		randarr[i] = rand();
}

int rand_index = 0;

void mySeedRand(int init)
{
	rand_index = init & (NRANDS-1);
}

unsigned long myRand()
{
	unsigned long rnd = randarr[rand_index++];
	rand_index &= NRANDS-1;
	return rnd;
}


unsigned long randbits(int howmany)
{
	unsigned long rnd = myRand();
	switch (howmany)
	{
	case 0:	return 0;
	case 1:	return (1<<(rnd&7));
	case 2:	return (1<<(rnd&7)) + ((1<<(rnd>>4)&7));
	case 3:	return (1<<(rnd&7)) + ((1<<(rnd>>4)&7)) + ((1<<(rnd>>8)&7));
	case 4:	return rnd & 0xff;
	case 5:	return (rnd | (rnd>>8) | (rnd>>16) | (rnd>>24)) & 0xff;
	}
	return 0xff;
}


void simple (int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();

	for (i = 0 ; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		if ( bits & (1<<0)) handleBit0();
		if ( bits & (1<<1)) handleBit1();
		if ( bits & (1<<2)) handleBit2();
		if ( bits & (1<<3)) handleBit3();
		if ( bits & (1<<4)) handleBit4();
		if ( bits & (1<<5)) handleBit5();
		if ( bits & (1<<6)) handleBit6();
		if ( bits & (1<<7)) handleBit7();
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("Simple   0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}



void reinhard(int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();

	for (i = 0 ; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		do
		{
			switch (bits)			{
			// cases [all odd numbers (with 0x01 matching)]:
			case 0x01: case 0x03: case 0x05: case 0x07:
                 	case 0x09: case 0x0b: case 0x0d: case 0x0f:
			case 0x11: case 0x13: case 0x15: case 0x17:
                 	case 0x19: case 0x1b: case 0x1d: case 0x1f:
			case 0x21: case 0x23: case 0x25: case 0x27:
                	case 0x29: case 0x2b: case 0x2d: case 0x2f:
			case 0x31: case 0x33: case 0x35: case 0x37:
                 	case 0x39: case 0x3b: case 0x3d: case 0x3f:
			case 0x41: case 0x43: case 0x45: case 0x47:
                 	case 0x49: case 0x4b: case 0x4d: case 0x4f:
			case 0x51: case 0x53: case 0x55: case 0x57:
                 	case 0x59: case 0x5b: case 0x5d: case 0x5f:
			case 0x61: case 0x63: case 0x65: case 0x67:
                	case 0x69: case 0x6b: case 0x6d: case 0x6f:
			case 0x71: case 0x73: case 0x75: case 0x77:
                 	case 0x79: case 0x7b: case 0x7d: case 0x7f:
			case 0x81: case 0x83: case 0x85: case 0x87:
                	case 0x89: case 0x8b: case 0x8d: case 0x8f:
			case 0x91: case 0x93: case 0x95: case 0x97:
                     	case 0x99: case 0x9b: case 0x9d: case 0x9f:
			case 0xa1: case 0xa3: case 0xa5: case 0xa7:
                	case 0xa9: case 0xab: case 0xad: case 0xaf:
			case 0xb1: case 0xb3: case 0xb5: case 0xb7:
                 	case 0xb9: case 0xbb: case 0xbd: case 0xbf:
			case 0xc1: case 0xc3: case 0xc5: case 0xc7:
                 	case 0xc9: case 0xcb: case 0xcd: case 0xcf:
			case 0xd1: case 0xd3: case 0xd5: case 0xd7:
                 	case 0xd9: case 0xdb: case 0xdd: case 0xdf:
			case 0xe1: case 0xe3: case 0xe5: case 0xe7:
                 	case 0xe9: case 0xeb: case 0xed: case 0xef:
			case 0xf1: case 0xf3: case 0xf5: case 0xf7:
                	case 0xf9: case 0xfb: case 0xfd: case 0xff:
				handleBit0();
				bits &= ~0x01;
				break;
			// cases [all numbers left with 0x02 matching]:
			case 0x02: case 0x06: case 0x0a: case 0x0e:
			case 0x12: case 0x16: case 0x1a: case 0x1e:
			case 0x22: case 0x26: case 0x2a: case 0x2e:
			case 0x32: case 0x36: case 0x3a: case 0x3e:
			case 0x42: case 0x46: case 0x4a: case 0x4e:
			case 0x52: case 0x56: case 0x5a: case 0x5e:
			case 0x62: case 0x66: case 0x6a: case 0x6e:
			case 0x72: case 0x76: case 0x7a: case 0x7e:
			case 0x82: case 0x86: case 0x8a: case 0x8e:
			case 0x92: case 0x96: case 0x9a: case 0x9e:
			case 0xa2: case 0xa6: case 0xaa: case 0xae:
			case 0xb2: case 0xb6: case 0xba: case 0xbe:
			case 0xc2: case 0xc6: case 0xca: case 0xce:
			case 0xd2: case 0xd6: case 0xda: case 0xde:
			case 0xe2: case 0xe6: case 0xea: case 0xee:
			case 0xf2: case 0xf6: case 0xfa: case 0xfe:
				handleBit1();
				bits &= ~0x02;
				break;
			// cases [all bits left with 0x04 matching]:
			case 0x04: case 0x0c:
			case 0x14: case 0x1c:
			case 0x24: case 0x2c:
			case 0x34: case 0x3c:
			case 0x44: case 0x4c:
			case 0x54: case 0x5c:
			case 0x64: case 0x6c:
			case 0x74: case 0x7c:
			case 0x84: case 0x8c:
			case 0x94: case 0x9c:
			case 0xa4: case 0xac:
			case 0xb4: case 0xbc:
			case 0xc4: case 0xcc:
			case 0xd4: case 0xdc:
			case 0xe4: case 0xec:
			case 0xf4: case 0xfc:
				handleBit2();
				bits &= ~0x04;
				break;
			case 0x08: case 0x18: case 0x28: case 0x38:
			case 0x48: case 0x58: case 0x68: case 0x78:
			case 0x88: case 0x98: case 0xa8: case 0xb8:
			case 0xc8: case 0xd8: case 0xe8: case 0xf8:
				handleBit3();
				bits &= ~0x08;
				break;
			case 0x10: case 0x30: case 0x50: case 0x70:
			case 0x90: case 0xb0: case 0xd0: case 0xf0:
				handleBit4();
				bits &= ~0x10;
				break;
			case 0x20: case 0x60: case 0xa0: case 0xe0:
				handleBit5();
				bits &= ~0x20;
				break;
			case 0x40: case 0xc0:
				handleBit6();
				bits &= ~0x40;
				break;
			case 0x80:
				handleBit7();
				bits = 0x00;
				break;
			default:
				bits = 0x00;
				break;
			}
		} while (bits);
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("Reinhard 0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}


void heiner (int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();

	for (i = 0 ; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		switch( smallestpower[bits] )
		{
		case 0:
			handleBit0();
			if (! (bits -= (1<<0))) goto rdy;
			if (bits & (1<<1))
			{
		case 1:
					handleBit1();
					if (! (bits -= (1<<1))) goto rdy;
			}
			if (bits & 0x0c)
			{
				if (bits & (1<<2))
				{
		case 2:
					handleBit2();
					if (! (bits -= (1<<2))) goto rdy;
				}
				if (bits & (1<<3))
				{
		case 3:
					handleBit3();
					if (! (bits -= (1<<3))) goto rdy;
				}
			}
			if (bits & 0xf0)
			{
				if (bits & 0x30)
				{
					if (bits & (1<<4))
					{
		case 4:
						handleBit4();
						if (! (bits -= (1<<4))) goto rdy;
					}
					if (bits & (1<<5))
					{
		case 5:
						handleBit5();
						if (! (bits -= (1<<5))) goto rdy;
					}
				}
				if (bits & 0xc0)
				{
					if (bits & (1<<6))
					{
		case 6:
						handleBit6();
					}
					if (bits & (1<<7))
					{
		case 7:
						handleBit7();
					}
				}
			}
		}
		rdy:;
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("Heiner   0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}


void tim (int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();
	for (i = 0 ; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		while (bits)
		{
			int bit = smallestpower[bits];
			switch (bit)
			{
				case 0: handleBit0(); break;
				case 1: handleBit1(); break;
				case 2: handleBit2(); break;
				case 3: handleBit3(); break;
				case 4: handleBit4(); break;
				case 5: handleBit5(); break;
				case 6: handleBit6(); break;
				case 7: handleBit7(); break;
			}
			bits ^= (1 << bit);
		}
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("Tim      0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}


void andrew (int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();
	for (i = 0; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		if ( bits & 0xc0 )
		{
			if ( bits & 0x80 ) handleBit7();
			if ( bits & 0x40 ) handleBit6();
			if ((bits &~0xc0) == 0 ) goto done;
		}
		if ( bits & 0x30 )
		{
			if ( bits & 0x20 ) handleBit5();
			if ( bits & 0x10 ) handleBit4();
			if ((bits &~0x30) == 0 ) goto done;
		}
		if ( bits & 0x0c )
		{
			if ( bits & 0x08 ) handleBit3();
			if ( bits & 0x04 ) handleBit2();
		}
		if ( bits & 0x03 )
		{
			if ( bits & 0x02 ) handleBit1();
			if ( bits & 0x01 ) handleBit0();
		}
		done:;
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("Andrew   0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}


void switch256 (int uptoNbits)
{
	int i;
	clock_t start, stop;

	mySeedRand(0);
	n = n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
	start = clock();
	for (i = 0; i < MAX_ITERATIONS; i++)
	{
		unsigned long bits = randbits(uptoNbits);
		switch (bits)
		{
		case 0x00:
			break;
		case 0x01:
			handleBit0();
			break;
		case 0x02:
			handleBit1();
			break;
		case 0x03:
			handleBit0();
			handleBit1();
			break;
		case 0x04:
			handleBit2();
			break;
		case 0x05:
			handleBit0();
			handleBit2();
			break;
		case 0x06:
			handleBit1();
			handleBit2();
			break;
		case 0x07:
			handleBit0();
			handleBit1();
			handleBit2();
			break;
		case 0x08:
			handleBit3();
			break;
		case 0x09:
			handleBit0();
			handleBit3();
			break;
		case 0x0a:
			handleBit1();
			handleBit3();
			break;
		case 0x0b:
			handleBit0();
			handleBit1();
			handleBit3();
			break;
		case 0x0c:
			handleBit2();
			handleBit3();
			break;
		case 0x0d:
			handleBit0();
			handleBit2();
			handleBit3();
			break;
		case 0x0e:
			handleBit1();
			handleBit2();
			handleBit3();
			break;
		case 0x0f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			break;
		case 0x10:
			handleBit4();
			break;
		case 0x11:
			handleBit0();
			handleBit4();
			break;
		case 0x12:
			handleBit1();
			handleBit4();
			break;
		case 0x13:
			handleBit0();
			handleBit1();
			handleBit4();
			break;
		case 0x14:
			handleBit2();
			handleBit4();
			break;
		case 0x15:
			handleBit0();
			handleBit2();
			handleBit4();
			break;
		case 0x16:
			handleBit1();
			handleBit2();
			handleBit4();
			break;
		case 0x17:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			break;
		case 0x18:
			handleBit3();
			handleBit4();
			break;
		case 0x19:
			handleBit0();
			handleBit3();
			handleBit4();
			break;
		case 0x1a:
			handleBit1();
			handleBit3();
			handleBit4();
			break;
		case 0x1b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			break;
		case 0x1c:
			handleBit2();
			handleBit3();
			handleBit4();
			break;
		case 0x1d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			break;
		case 0x1e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			break;
		case 0x1f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			break;
		case 0x20:
			handleBit5();
			break;
		case 0x21:
			handleBit0();
			handleBit5();
			break;
		case 0x22:
			handleBit1();
			handleBit5();
			break;
		case 0x23:
			handleBit0();
			handleBit1();
			handleBit5();
			break;
		case 0x24:
			handleBit2();
			handleBit5();
			break;
		case 0x25:
			handleBit0();
			handleBit2();
			handleBit5();
			break;
		case 0x26:
			handleBit1();
			handleBit2();
			handleBit5();
			break;
		case 0x27:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit5();
			break;
		case 0x28:
			handleBit3();
			handleBit5();
			break;
		case 0x29:
			handleBit0();
			handleBit3();
			handleBit5();
			break;
		case 0x2a:
			handleBit1();
			handleBit3();
			handleBit5();
			break;
		case 0x2b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit5();
			break;
		case 0x2c:
			handleBit2();
			handleBit3();
			handleBit5();
			break;
		case 0x2d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit5();
			break;
		case 0x2e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			break;
		case 0x2f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			break;
		case 0x30:
			handleBit4();
			handleBit5();
			break;
		case 0x31:
			handleBit0();
			handleBit4();
			handleBit5();
			break;
		case 0x32:
			handleBit1();
			handleBit4();
			handleBit5();
			break;
		case 0x33:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit5();
			break;
		case 0x34:
			handleBit2();
			handleBit4();
			handleBit5();
			break;
		case 0x35:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit5();
			break;
		case 0x36:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			break;
		case 0x37:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			break;
		case 0x38:
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x39:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3a:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3c:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x3f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			break;
		case 0x40:
			handleBit6();
			break;
		case 0x41:
			handleBit0();
			handleBit6();
			break;
		case 0x42:
			handleBit1();
			handleBit6();
			break;
		case 0x43:
			handleBit0();
			handleBit1();
			handleBit6();
			break;
		case 0x44:
			handleBit2();
			handleBit6();
			break;
		case 0x45:
			handleBit0();
			handleBit2();
			handleBit6();
			break;
		case 0x46:
			handleBit1();
			handleBit2();
			handleBit6();
			break;
		case 0x47:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit6();
			break;
		case 0x48:
			handleBit3();
			handleBit6();
			break;
		case 0x49:
			handleBit0();
			handleBit3();
			handleBit6();
			break;
		case 0x4a:
			handleBit1();
			handleBit3();
			handleBit6();
			break;
		case 0x4b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit6();
			break;
		case 0x4c:
			handleBit2();
			handleBit3();
			handleBit6();
			break;
		case 0x4d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit6();
			break;
		case 0x4e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit6();
			break;
		case 0x4f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit6();
			break;
		case 0x50:
			handleBit4();
			handleBit6();
			break;
		case 0x51:
			handleBit0();
			handleBit4();
			handleBit6();
			break;
		case 0x52:
			handleBit1();
			handleBit4();
			handleBit6();
			break;
		case 0x53:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit6();
			break;
		case 0x54:
			handleBit2();
			handleBit4();
			handleBit6();
			break;
		case 0x55:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit6();
			break;
		case 0x56:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit6();
			break;
		case 0x57:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit6();
			break;
		case 0x58:
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x59:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5a:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5c:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x5f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			break;
		case 0x60:
			handleBit5();
			handleBit6();
			break;
		case 0x61:
			handleBit0();
			handleBit5();
			handleBit6();
			break;
		case 0x62:
			handleBit1();
			handleBit5();
			handleBit6();
			break;
		case 0x63:
			handleBit0();
			handleBit1();
			handleBit5();
			handleBit6();
			break;
		case 0x64:
			handleBit2();
			handleBit5();
			handleBit6();
			break;
		case 0x65:
			handleBit0();
			handleBit2();
			handleBit5();
			handleBit6();
			break;
		case 0x66:
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit6();
			break;
		case 0x67:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit6();
			break;
		case 0x68:
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x69:
			handleBit0();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6a:
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6c:
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x6f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			break;
		case 0x70:
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x71:
			handleBit0();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x72:
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x73:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x74:
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x75:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x76:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x77:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x78:
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x79:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7a:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7c:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x7f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			break;
		case 0x80:
			handleBit7();
			break;
		case 0x81:
			handleBit0();
			handleBit7();
			break;
		case 0x82:
			handleBit1();
			handleBit7();
			break;
		case 0x83:
			handleBit0();
			handleBit1();
			handleBit7();
			break;
		case 0x84:
			handleBit2();
			handleBit7();
			break;
		case 0x85:
			handleBit0();
			handleBit2();
			handleBit7();
			break;
		case 0x86:
			handleBit1();
			handleBit2();
			handleBit7();
			break;
		case 0x87:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit7();
			break;
		case 0x88:
			handleBit3();
			handleBit7();
			break;
		case 0x89:
			handleBit0();
			handleBit3();
			handleBit7();
			break;
		case 0x8a:
			handleBit1();
			handleBit3();
			handleBit7();
			break;
		case 0x8b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit7();
			break;
		case 0x8c:
			handleBit2();
			handleBit3();
			handleBit7();
			break;
		case 0x8d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit7();
			break;
		case 0x8e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit7();
			break;
		case 0x8f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit7();
			break;
		case 0x90:
			handleBit4();
			handleBit7();
			break;
		case 0x91:
			handleBit0();
			handleBit4();
			handleBit7();
			break;
		case 0x92:
			handleBit1();
			handleBit4();
			handleBit7();
			break;
		case 0x93:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit7();
			break;
		case 0x94:
			handleBit2();
			handleBit4();
			handleBit7();
			break;
		case 0x95:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit7();
			break;
		case 0x96:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit7();
			break;
		case 0x97:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit7();
			break;
		case 0x98:
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x99:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9a:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9b:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9c:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9d:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9e:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x9f:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit7();
			break;
		case 0x0a0:
			handleBit5();
			handleBit7();
			break;
		case 0x0a1:
			handleBit0();
			handleBit5();
			handleBit7();
			break;
		case 0x0a2:
			handleBit1();
			handleBit5();
			handleBit7();
			break;
		case 0x0a3:
			handleBit0();
			handleBit1();
			handleBit5();
			handleBit7();
			break;
		case 0x0a4:
			handleBit2();
			handleBit5();
			handleBit7();
			break;
		case 0x0a5:
			handleBit0();
			handleBit2();
			handleBit5();
			handleBit7();
			break;
		case 0x0a6:
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit7();
			break;
		case 0x0a7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit7();
			break;
		case 0x0a8:
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0a9:
			handleBit0();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0aa:
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0ab:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0ac:
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0ad:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0ae:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0af:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit7();
			break;
		case 0x0b0:
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b1:
			handleBit0();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b2:
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b3:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b4:
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b5:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b6:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b8:
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0b9:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0ba:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0bb:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0bc:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0bd:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0be:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0bf:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit7();
			break;
		case 0x0c0:
			handleBit6();
			handleBit7();
			break;
		case 0x0c1:
			handleBit0();
			handleBit6();
			handleBit7();
			break;
		case 0x0c2:
			handleBit1();
			handleBit6();
			handleBit7();
			break;
		case 0x0c3:
			handleBit0();
			handleBit1();
			handleBit6();
			handleBit7();
			break;
		case 0x0c4:
			handleBit2();
			handleBit6();
			handleBit7();
			break;
		case 0x0c5:
			handleBit0();
			handleBit2();
			handleBit6();
			handleBit7();
			break;
		case 0x0c6:
			handleBit1();
			handleBit2();
			handleBit6();
			handleBit7();
			break;
		case 0x0c7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit6();
			handleBit7();
			break;
		case 0x0c8:
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0c9:
			handleBit0();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0ca:
			handleBit1();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0cb:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0cc:
			handleBit2();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0cd:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0ce:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0cf:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit6();
			handleBit7();
			break;
		case 0x0d0:
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d1:
			handleBit0();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d2:
			handleBit1();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d3:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d4:
			handleBit2();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d5:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d6:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d8:
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0d9:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0da:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0db:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0dc:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0dd:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0de:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0df:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit6();
			handleBit7();
			break;
		case 0x0e0:
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e1:
			handleBit0();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e2:
			handleBit1();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e3:
			handleBit0();
			handleBit1();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e4:
			handleBit2();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e5:
			handleBit0();
			handleBit2();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e6:
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e8:
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0e9:
			handleBit0();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ea:
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0eb:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ec:
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ed:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ee:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ef:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f0:
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f1:
			handleBit0();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f2:
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f3:
			handleBit0();
			handleBit1();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f4:
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f5:
			handleBit0();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f6:
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f7:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f8:
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0f9:
			handleBit0();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0fa:
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0fb:
			handleBit0();
			handleBit1();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0fc:
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0fd:
			handleBit0();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0fe:
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		case 0x0ff:
			handleBit0();
			handleBit1();
			handleBit2();
			handleBit3();
			handleBit4();
			handleBit5();
			handleBit6();
			handleBit7();
			break;
		}
	}
	stop = clock();
	n = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8;
	printf("switch   0x%08x, time = %.3f\n", n, (float)(stop - start) /
CLOCKS_PER_SEC);
}

char* title[] =
{
	"\nzero byte:\n",
	"\nlonesome one bit:\n",
	"\nup to two one bits:\n",
	"\nup to three one bits:\n",
	"\neight random bits:\n",
	"\neight random bits high one probability:\n",
	"\neight one bits 0xff:\n"
};


void main (void)
{
	initRand();
	for (int i = 1; i <= 6; i++)
	{
		printf(title[i]);
		simple (i);
		andrew(i);
		tim(i);
		heiner (i);
		reinhard (i);
		switch256(i);
	}
}







This page took 0.01 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.