CODE:
#include
#include
#define ITERATION_NUM 1000000000
int main(void) {
LARGE_INTEGER start,end;
LARGE_INTEGER freq;
LARGE_INTEGER result;
int i;
int test_int=0;
short test_short=0;
char test_char=0;
long long test_long_long=0;
double test_double=0;
float test_float=0;
long double test_long_double=0;
if(!QueryPerformanceFrequency(&freq)) {
puts("パフォーマンスカウンタに非対応です。");
return 1;
}
printf("パフォーマンスカウンタ周波数 : %lldHz\n",(long long)freq.QuadPart);
printf(" ループ回数 : %d回\n",ITERATION_NUM);
printf(" 空転 : ");
QueryPerformanceCounter(&start);
for(i=0;i
#include
#define ITERATION_NUM 1000000000
int main(void) {
LARGE_INTEGER start,end;
LARGE_INTEGER freq;
LARGE_INTEGER result;
int i;
int test_int=0;
short test_short=0;
char test_char=0;
long long test_long_long=0;
double test_double=0;
float test_float=0;
long double test_long_double=0;
if(!QueryPerformanceFrequency(&freq)) {
puts("パフォーマンスカウンタに非対応です。");
return 1;
}
printf("パフォーマンスカウンタ周波数 : %lldHz\n",(long long)freq.QuadPart);
printf(" ループ回数 : %d回\n",ITERATION_NUM);
printf(" 空転 : ");
QueryPerformanceCounter(&start);
for(i=0;i
#include
#define ITERATION_NUM 1000000000
int main(void) {
LARGE_INTEGER start,end;
LARGE_INTEGER freq;
LARGE_INTEGER result;
int i;
int test_int=0;
short test_short=0;
char test_char=0;
long long test_long_long=0;
double test_double=0;
float test_float=0;
long double test_long_double=0;
if(!QueryPerformanceFrequency(&freq)) {
puts("パフォーマンスカウンタに非対応です。");
return 1;
}
printf("パフォーマンスカウンタ周波数 : %lldHz\n",(long long)freq.QuadPart);
printf(" ループ回数 : %d回\n",ITERATION_NUM);
printf(" 空転 : ");
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++);
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" int乗算 : ");
test_int=0;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_int=69719;
test_int=test_int*53;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" short乗算 : ");
test_short=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_short=(short)691;
test_short=test_short*(short)53;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" char乗算 : ");
test_char=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_char=(char)2;
test_char=test_char*(char)53;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" long long乗算 : ");
test_long_long=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_long_long=84932902030553ll;
test_long_long=test_long_long*53ll;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" double乗算 : ");
test_double=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_double=1489.0;
test_double=test_double*53.0;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf(" float乗算 : ");
test_float=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_float=1489.0f;
test_float=test_float*53.0f;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
printf("long double乗算 : ");
test_long_double=1;
QueryPerformanceCounter(&start);
for(i=0;i<ITERATION_NUM;i++) {
test_long_double=1489.0l;
test_long_double=test_long_double*53.0l;
}
QueryPerformanceCounter(&end);
result.QuadPart=end.QuadPart-start.QuadPart;
printf("%13.6fms(%12lld)\n",(double)result.QuadPart/freq.QuadPart*1000.0,result.QuadPart);
return 0;
}