我在Windows 7旗舰版上运行XAMPP 1.7.1。一切(Apache& MySQL)工作正常,除了速度。
当我打开http://localhost/,我必须等待大约1-3秒查看一个网页。在我看来,它应该是最多几百毫秒。
基本事实:
>在等待加载本地主机网页时,状态栏会显示“Waiting for localhost …”
> CPU仍然空闲(加载时没有增加的活动)
> on localhost是没有要求的PHP脚本,问题是当有简单的phpinfo()即使有长的重脚本。
>禁用MySQL服务器不影响速度
>我的电脑:AMD Turion 64 X2; 1,6 GHz双核,2 GB RAM,100 GB HDD
我做了一个简单的基准PHP脚本来测试HDD / CSS速度:
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function testReadWrite() {
$timeStart = getmicrotime();
$filename = "test.txt";
file_put_contents( $filename, '' ); // prepare empty file
for ( $i = 0; $i < 1000; $i++ ) {
$a = file_get_contents( $filename );
file_put_contents( $filename, $a . '.' );
}
return round( getmicrotime() - $timeStart, 3 );
}
function testCpuSpeed() {
$timeStart = getmicrotime();
$var = '';
for ( $i = 0; $i < 100000; $i++ ) {
$var = sha1( md5( $i * $i * $i * $i * $i * $i * $i * $i * $i * $i ) );
}
return round( getmicrotime() - $timeStart, 3 );
}
echo "Read/write #1: " . testReadWrite() . "
";
echo "Read/write #2: " . testReadWrite() . "
";
echo "Read/write #3: " . testReadWrite() . "
";
echo "CPU speed #1: " . testCpuSpeed() . "
";
echo "CPU speed #2: " . testCpuSpeed() . "
";
echo "CPU speed #3: " . testCpuSpeed() . "
";
?>
我的PC结果:
>读/写:5.134 / 3.431 / 3.494
> CPU速度:0.816 / 0.767 / 0.795
主机结果:
>读/写:7.768 / 7.69 / 7.371
> CPU速度:0.232 / 0.234 / 0.234
我的一个服务器的结果(作为空闲的计算机几乎像我的电脑,但有点快):
>读/写:0.088 / 0.168 / 0.185
> CPU速度:0.191 / 0.189 / 0.189
所以我不认为这是因为我的电脑速度,但我敢肯定有另一个问题。
你有在Windows 7(或Vista)XAMPP速度的一些经验吗?
谢谢。