Gac*_*cek 5 ssd hard-drive speed php windows-10
我最近注意到,我在 Windows 10 上设置的开发服务器非常慢。
我用 xdebug 做了一些调试/分析(Prestashop 1.6),罪魁祸首是 file_exists。脚本加载时间为 43 秒,而 file_exist 需要约 40 秒。
我写了一个小测试,看看我的 Windows 10 机器和旧的 Centos7 笔记本电脑的性能如何。这是脚本:
<?php
$microtime = microtime(true);
function displayCounter($txt){
global $microtime;
echo "<p> {$txt}: ". round((microtime(true) - $microtime) * 1000,0) ."ms</p>";
$microtime = microtime(true);
}
$file_prefix = __DIR__ . '/file';
for($i= 1; $i < 1000; $i++){
file_put_contents($file_prefix . $i, '');
}
displayCounter('File Creation');
for($i= 1; $i < 1000; $i++){
file_exists($file_prefix . $i);
}
displayCounter('file_exists');
clearstatcache();
for($i= 1; $i < 1000; $i++){
file_exists($file_prefix . $i);
}
displayCounter('file_exists (after cache clear)');
for($i= 1; $i < 1000; $i++){
unlink($file_prefix . $i);
}
displayCounter('unlink');
Run Code Online (Sandbox Code Playgroud)
Windows 服务器基于SSD驱动器,结果为:
File Creation: 1992ms
file_exists: 1055ms
file_exists (after cache clear): 963ms
unlink: 696ms
Run Code Online (Sandbox Code Playgroud)
和 linux(带有5400rpm HDD驱动器的笔记本电脑)
File Creation: 226ms
file_exists: 5ms
file_exists (after cache clear): 4ms
unlink: 50ms
Run Code Online (Sandbox Code Playgroud)
我认为这里出了点问题,但还不知道是什么 - 所以我来这里寻求帮助。
无法解决这里的问题。我应该寻找什么“服务”?像 Defender(在我的情况下被禁用)
使用相同的脚本进行了更多测试。重复几次检查,结果如下。您从中调用脚本的目录很重要。仍然找不到破坏它的东西(除非我知道它是 Windows...)
所有测试(M.2 驱动器除外)在当前cmd
路径设置在工作完成的地方时都很好。
C: M.2
H: SSD
D: SSDHD
F: / E: HDD
(GPT) Current Folder C:\ (M.2)
D:\test_file_exists\test.php (SSDHD)
File Creation: 2541ms
file_exists: 1188ms
file_exists (cached in theory): 986ms
file_exists (after cache clear): 879ms
unlink: 1361ms
(GPT) Current Folder C:\ (M.2)
E:\test_file_exists\test.php (HDD)
File Creation: 2617ms
file_exists: 1031ms
file_exists (cached in theory): 893ms
file_exists (after cache clear): 841ms
unlink: 1156ms
(MBR) Current Folder C:\ (M.2)
C:\test_file_exists\test.php (M.2)
File Creation: 2485ms
file_exists: 2283ms
file_exists (cached in theory): 2045ms
file_exists (after cache clear): 2053ms
unlink: 1191ms
(MBR) Current Folder C:\ (M.2)
F:\test_file_exists\test.php (HDD)
File Creation: 2274ms
file_exists: 1080ms
file_exists (cached in theory): 922ms
file_exists (after cache clear): 838ms
unlink: 1105ms
(MBR) Current Folder C:\ (M.2)
H:\test_file_exists\test.php (SSD)
File Creation: 2243ms
file_exists: 1024ms
file_exists (cached in theory): 860ms
file_exists (after cache clear): 903ms
unlink: 1134ms
=============== TESTS STARTED IN ROOT OF VOLUME
(GPT) Current Folder D:\ (SSDHD)
D:\test_file_exists\test.php (SSDHD)
File Creation: 2277ms
file_exists: 1056ms
file_exists (cached in theory): 904ms
file_exists (after cache clear): 897ms
unlink: 1135ms
(GPT) Current Folder E:\ (HDD)
E:\test_file_exists\test.php (HDD)
File Creation: 2436ms
file_exists: 1116ms
file_exists (cached in theory): 844ms
file_exists (after cache clear): 849ms
unlink: 1145ms
(MBR) Current Folder C:\ (M.2)
C:\test_file_exists\test.php (M.2)
File Creation: 2311ms
file_exists: 2115ms
file_exists (cached in theory): 1986ms
file_exists (after cache clear): 1969ms
unlink: 1168ms
(MBR) Current Folder F:\ (HDD)
F:\test_file_exists\test.php (HDD)
File Creation: 2365ms
file_exists: 1031ms
file_exists (cached in theory): 961ms
file_exists (after cache clear): 849ms
unlink: 1112ms
(MBR) Current Folder H:\ (SSD)
H:\test_file_exists\test.php (SSD)
File Creation: 2251ms
file_exists: 1066ms
file_exists (cached in theory): 873ms
file_exists (after cache clear): 835ms
unlink: 1137ms
=============== TESTS STARTED IN FOLDER OF SCRIPT
(GPT) Current Folder D:\test_file_exists (SSDHD)
D:\test_file_exists\test.php (SSDHD)
File Creation: 1279ms
file_exists: 61ms
file_exists (cached in theory): 60ms
file_exists (after cache clear): 51ms
unlink: 1873ms
(GPT) Current Folder E:\test_file_exists (HDD)
E:\test_file_exists\test.php (HDD)
File Creation: 1395ms
file_exists: 68ms
file_exists (cached in theory): 59ms
file_exists (after cache clear): 48ms
unlink: 1183ms
(MBR) Current Folder C:\test_file_exists (M.2)
C:\test_file_exists\test.php (M.2)
File Creation: 1410ms
file_exists: 1261ms
file_exists (cached in theory): 1293ms
file_exists (after cache clear): 1298ms
unlink: 1129ms
(MBR) Current Folder F:\test_file_exists (HDD)
F:\test_file_exists\test.php (HDD)
File Creation: 1285ms
file_exists: 58ms
file_exists (cached in theory): 61ms
file_exists (after cache clear): 57ms
unlink: 1639ms
(MBR) Current Folder H:\test_file_exists (SSD)
H:\test_file_exists\test.php (SSD)
File Creation: 1365ms
file_exists: 72ms
file_exists (cached in theory): 55ms
file_exists (after cache clear): 62ms
unlink: 1092ms
Run Code Online (Sandbox Code Playgroud)
发帖者现在报告说,根据我的建议,他以安全模式启动后,他的问题已经消失。
有时确实会发生这样的情况:在安全模式下运行可以让 Windows 解决问题。有时,重新启动几次即可解决问题。也许两者的结合在这里有所帮助。
如果问题是通过我的建议的副作用偶然解决的,那就太搞笑了。
这不应损害我在下面的原始答案中概述的过程的有效性,该过程旨在检测在安全模式下启动时被禁用的有问题的产品。
原答案
在带网络的安全模式下启动时,一切正常 。在此模式下,Windows 仅以核心驱动程序和网络支持启动,尤其是在启动时不会启动任何第三方应用程序或驱动程序。
因此,您的速度变慢很可能是由计算机上安装的某些产品引起的。因此,您需要找到并禁用它。
我不知道速度变慢是否仅限于 PHP。在我的回答的其余部分中,我将讨论一般的 Windows 情况。但如果问题仅限于 PHP,则可能是由 PHP 本身的某些附加组件引起的。
有助于发现已安装产品问题的最佳产品是 autoruns,您可以通过它一键关闭或重新打开启动产品。
有关使用自动运行的信息,请参阅本文:
使用自动运行来处理启动进程和恶意软件。
Autoruns 将在其 Everything 选项卡中显示所有启动产品。我建议研究一下这份清单,寻找任何可能引起共鸣的东西。如果没有想到,您可以通过关闭产品块并每次重新启动来使用暴力,优化禁用产品的数量,直到找到该产品。
找到该产品后,您可以选择是否永久卸载它、寻找更新版本或联系开发人员。我们也来这里寻求帮助。
归档时间: |
|
查看次数: |
917 次 |
最近记录: |