请关注:::质疑BCB6的算术运算能力!
/*
test64.c
本程序用于测试unsigned __int64的性能。
根据测试结果,BCB6的命令行编译器BCC32 V5.6.4,
ilink32 V5.64对unsigned __int64的支持不好。
特别是对大于2^32的数进行求余和除法时性能很差!!
以下是我的测试结果。
(IBM笔记本PIII850/128M+WindowsXP Pro)
---------------------------------------------
测试加法(小于2^32)
用时:3655
测试加法(大于2^32)
用时:3595
测试开方(小于2^32)
10000
用时:21481
测试开方(大于2^32)
207484
用时:20760
测试求余(小于2^32)
94967337
用时:6449
测试求余(大于2^32)
94967339
用时:108286
测试除法(小于2^32)
42
用时:6239
测试除法(大于2^32)
42
用时:106473
*/
#include <math.h>
#include <windows.h>
#include <stdio.h>
/* */
int main(void)
{
unsigned __int64 a=0;
unsigned long i, j, k;
DWORD ts;
printf("测试加法(小于2^32)\n");
ts=GetTickCount();
for(i=0; i < 1000000000; ++i)
{
++a;
}
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试加法(大于2^32)\n");
ts=GetTickCount();
a=4294967296;
for(i=0; i < 1000000000; ++i)
{
++a;
}
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试开方(小于2^32)\n");
ts=GetTickCount();
a=0;
for(i=0; i < 100000000; ++i)
{
++a;
k=sqrt((double)a);
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试开方(大于2^32)\n");
ts=GetTickCount();
a=42949672960;
for(i=0; i < 100000000; ++i)
{
++a;
k=sqrt((double)a);
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试求余(小于2^32)\n");
ts=GetTickCount();
a=4294967295;
for(i=2; i < 100000000; ++i)
{
k=a % i;
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试求余(大于2^32)\n");
ts=GetTickCount();
a=4294967297;
for(i=2; i < 100000000; ++i)
{
k=a % i;
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试除法(小于2^32)\n");
ts=GetTickCount();
a=4294967295;
for(i=2; i < 100000000; ++i)
{
k=a / i;
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
printf("测试除法(大于2^32)\n");
ts=GetTickCount();
a=4294967297;
for(i=2; i < 100000000; ++i)
{
k=a / i;
}
printf("%lu\n", k);
printf("用时:%lu\n", GetTickCount() - ts);
return 0;
}