1

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 :).

Michel Rummens
  • 459
  • 3
  • 9
  • 1
    It's probably some overhead in the windows version of PHP - emulation or somesuch in the stack. Unless a PHP or Windows dev reads this I don't know if you'll get a definitive answer. Why are you concerned about this? You wouldn't host a live application in Windows 10, so it won't affect real world performance. – ADyson Mar 05 '19 at 09:24
  • Sorry for the slow respond, was hoping on some answers still. I am concerned about this, because i have a live server that executes this even slower (apache running on centOS), so i hoped for a quickfix based on those minor details. Figured the cause of difference in execution time could be similar to the difference between my bash (ubuntu)- and windows installation. I am now going to use some profiling tools, hope this will help me allocate my problem. thanks for taking the time to respond! – Michel Rummens Mar 06 '19 at 14:59

0 Answers0