/*
Basic benchmarking program (measures the speed of your comp)
Makes use of high-performance timers for high precision
Greg Toombs
Last edited March 26, 2001
Previous results:
Kate's computer: 1.634
My computer: 1.168
Geoff's computer: 0.446
Email me yours.
toombs@hurontel.on.ca
*/
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
/*
void doLargeIntString(signed __int64 number, char* string, int limit) {
signed __int64 place = 10;
for (int i = 0; i < limit && number > 0; i++) {
string[i] = ((unsigned char)((number % place) / (place / 10))) + '0';
number -= number % place;
place *= 10;
}
strrev(string);
}
*/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
LARGE_INTEGER freq, count, count2;
bool ok = QueryPerformanceFrequency(&freq);
if (!ok) {
MessageBox(0, "Performance timers aren't supported.", "Error", MB_OK);
return 0;
}
Sleep(500);
QueryPerformanceCounter(&count);
double work = 0, cycle = 0;
for (int i = 0; i < 10000; i++) {
work += sin(cycle) * 0.357;
work -= sin(cycle) * 2.9348;
if (cycle > 3.1415926536 * 2) cycle = 0;
}
QueryPerformanceCounter(&count2);
SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
double dcount = ((double)(count2.QuadPart - count.QuadPart)) / ((double)freq.QuadPart) * 1000;
char string[50] = "";
sprintf(string, "The operation took %f milliseconds.", dcount);
MessageBox(0, string, "Info", MB_OK);
return 0;
}