#include #include #include #include #define FIVEK 5000 #define TENK 10000 #define ONEHUNK 100000 #define ONEMIL 1000000 #define MEMORY_TEST 200000000 VOID _fastcall MemToReg ( IN ULONG Count, IN PULONG Address ); VOID _fastcall RegToMem ( IN ULONG Count, IN PULONG Address ); // // Define local types. // typedef struct _PERFINFO { DWORD StartTime; DWORD StopTime; LPSTR Title; DWORD Iterations; } PERFINFO, *PPERFINFO; VOID FinishBenchMark ( IN PPERFINFO PerfInfo ) { DWORD ContextSwitches; DWORD Duration; DWORD Performance; // // Print results and announce end of test. // PerfInfo->StopTime = GetTickCount(); Duration = PerfInfo->StopTime - PerfInfo->StartTime; printf(" Test time in milliseconds %d\n", Duration); printf(" Number of iterations %d\n", PerfInfo->Iterations); Performance = PerfInfo->Iterations * 1000 / Duration; printf(" Iterations per second %d\n", Performance); printf("*** End of Test ***\n\n"); return; } VOID StartBenchMark ( IN PCHAR Title, IN DWORD Iterations, IN PPERFINFO PerfInfo ) { // // Announce start of test and the number of iterations. // printf("*** Start of test ***\n %s\n", Title); PerfInfo->Title = Title; PerfInfo->Iterations = Iterations; PerfInfo->StartTime = GetTickCount(); return; } VOID VqTest( VOID ) { PERFINFO PerfInfo; int i; PVOID Pv; DWORD dw; MEMORY_BASIC_INFORMATION BasicInfo; // // Reserve 64k and commit one page // Pv = VirtualAlloc(NULL,65536,MEM_RESERVE,PAGE_READWRITE); if ( !Pv ) { printf("Virtual Alloc(a) Failed %d\n",GetLastError()); ExitProcess(1); } Pv = VirtualAlloc(Pv,4096,MEM_COMMIT,PAGE_READWRITE); if ( !Pv ) { printf("Virtual Alloc(b) Failed %d\n",GetLastError()); ExitProcess(1); } SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS); StartBenchMark( "Virtual Query Test", 5*ONEHUNK, &PerfInfo ); for ( i=0;i<5*ONEHUNK;i++) { dw = VirtualQuery(Pv,&BasicInfo,sizeof(BasicInfo)); } FinishBenchMark(&PerfInfo); SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); } VOID MulDivTest( VOID ) { PERFINFO PerfInfo; int i; SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS); StartBenchMark( "MulDiv(4,2,5) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(4,2,5); } FinishBenchMark(&PerfInfo); StartBenchMark( "MulDiv(-4,2,5) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(-4,2,5); } FinishBenchMark(&PerfInfo); StartBenchMark( "MulDiv(4,-2,5) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(4,-2,5); } FinishBenchMark(&PerfInfo); StartBenchMark( "MulDiv(-4,-2,5) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(-4,-2,5); } FinishBenchMark(&PerfInfo); StartBenchMark( "MulDiv(0x10,0x400,0) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(0x10,0x400,0); } FinishBenchMark(&PerfInfo); StartBenchMark( "MulDiv(0x10,0x40000000,2) Test", 5*ONEMIL, &PerfInfo ); for ( i=0;i<5*ONEMIL;i++) { MulDiv(0x10,0x40000000,2); } FinishBenchMark(&PerfInfo); SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); } VOID GfaTest( LPSTR Str ) { PERFINFO PerfInfo; int i; StartBenchMark( "GetFileAttributes Test", FIVEK, &PerfInfo ); for ( i=0;i 1 ) { // GfaTest(argv[1]); // } // FibTst(); MemoryTest(); return 0; }