Path: utzoo!attcan!uunet!wuarchive!mit-eddie!bu.edu!orc!inews!iwarp.intel.com!gargoyle!chinet!kdb From: kdb@chinet.chi.il.us (Karl Botts) Newsgroups: comp.os.msdos.programmer Subject: MSC 6.0 Message-ID: <1990Nov06.021342.21462@chinet.chi.il.us> Date: 6 Nov 90 02:13:42 GMT Organization: Chinet - Public Access UNIX Lines: 55 If you wanna see some aggressive optimization, compile this with MSC 6.0 using -Od, then with -Ox, execute 'em, and compare the results (L model; I haven't tried the others). --------------------------- cut --------------------- /* kdb$hpb 19:41:01 11/05/90 */ #include #include typedef unsigned short word; #define loword(d) (*((word *)&(d))) #define hiword(d) (*(((word *)&(d)+1))) #define HASHPAGE(pg, fd) (loword(pg) ^ hiword(pg) ^ fd * 5821) #ifndef NUM_CHAINS #define NUM_CHAINS 32 #endif long lrand() { long l; loword(l) = rand(); hiword(l) = rand(); return(l); } main() { int fd; long l; long chains[NUM_CHAINS]; for ( fd = 0; fd < _NFILE; fd++ ) { word hash; memset(chains, 0, sizeof(chains)); for ( l = 0; l < 100000; l++ ) { long x = lrand(); hash = HASHPAGE(x, fd); hash %= NUM_CHAINS; chains[hash]++; } for ( hash = 0; hash < NUM_CHAINS; hash++ ) printf("%ld%c", chains[hash], (hash + 1) % 16 ? ' ' : '\n'); printf("\n"); } return 0; }