douniewei6346 2019-03-05 09:16
浏览 106

通过windows的bash终端安装的php执行速度比windows 10的php快

The bash terminal used was installed using this tutorial. I don't think using a different cli matters for the execution time of php (as there was no difference between git bash and windows cmd) but for the purpose of making a clear distinction, I refer to it as "executed from bash" (refering to Ubuntu bash terminal), or "executed from git bash" (refering to the git bash terminal for Windows 10).

I have executed the script below a bunch of ways:

1: two seperate windows computers with a MAMP (Pro) and XAMPP stack, which had similar outcomes averaging at about 5.9 seconds.

2: Executed it with php for windows 10 without a LAMP or XAMPP stack, averaging at about 5.1 seconds.

3: However, when I execute this code via a Bash terminal (PHP 7.1.26-1+ubuntu18.04.1+deb.sury.org+1 (cli)) the avg execution time is around 2.9 seconds.

<?php    
$j=0;
$startTime = microtime(1);

for($i = 0; $i < 199999999; $i++ ){
        $j+=4;
    }

$time = microtime(1) - $startTime;
exit(var_dump($time));

What I have done so far

Tried running it with -n parameter (which disables the php.ini) from cli so any extensions that could be slowing the proces down would be disabled, but this made no difference:

php test.php -n

Tried running it as webserver to see if it would make a difference, and this caused the server started from BASH terminal to be 300ms faster than executed in cli, so 2.6 seconds. However, it did not matter for the command executed from git bash:

php -S localhost:8080 -n

Measured differences between real, user and system time, which has quite a big difference in outcome, averaged 10 times on git bash and bash:

Bash
real: 0m2.993s
user: 0m2.938s
sys: 0m0.063s

Git bash
real: 0m5.923s
user: 0m0.015s
sys: 0m0.030s

time php test.php -n

I have no clue where to look further, as it's just the php execution time i am concerned about, for now. Hope someone can help :).

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本