CPU 負荷のシナリオをチェックするために、この小さなプログラムを C++ で作成しました。
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
int main()
{
double x = 1;
int t1 = GetTickCount();
srand(10000);
for (unsigned long i = 0; i < 10000000; i++)
{
int r = rand();
double l = sqrt((double)r);
x *= log(l/3) * pow(x, r);
}
int t2 = GetTickCount();
printf("Time: %d\r\n", t2-t1);
getchar();
}
x86 用と win7 x64 上の x64 用の両方をコンパイルしました。
x64版だとなぜか3秒くらいで終わっ
たのに、x86版でやってみると48(!!!)秒かかりました。
何度も試しましたが、いつも同じような結果が得られました。
この違いの原因は何ですか?