php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71932 Low performance with bit operation
Submitted: 2016-03-31 10:59 UTC Modified: 2016-04-01 02:15 UTC
From: jacky at xsteach dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: Irrelevant OS: Mac OS X 10.11
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jacky at xsteach dot com
New email:
PHP Version: OS:

 

 [2016-03-31 10:59 UTC] jacky at xsteach dot com
Description:
------------
Bit operation on php 5.6+ is lower performance than php 5.5-.
php5.5 is faster 3x+ than php5.6 and php7.0.

$ php5 -v
PHP 5.5.31 (cli) (built: Feb 20 2016 20:33:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

$php5 demo.php 
Done in 0.047697067260742 seconds

$ php -v
PHP 5.6.19 (cli) (built: Mar  6 2016 14:18:03) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Retinas

$ php demo.php 
Done in 0.15873312950134 seconds

$ php7 -v
PHP 7.0.4 (cli) (built: Mar  6 2016 14:30:59) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.0RC4-dev, Copyright (c) 2002-2015, by Derick Rethans

$ php7 demo.php 
Done in 0.10964512825012 seconds

Test script:
---------------
<?php
function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

$time_start = microtime_float();


$i = 1920 * 1080;
$a = 1;
while ($i--) {
        $a << 1;
}

$time_end = microtime_float();
$time = $time_end - $time_start;

echo "Done in $time seconds\n";

Expected result:
----------------
Bit operation on php7.0 as faster as php5.5 or even better.

Actual result:
--------------
Low performance with bit operation on php7.0.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-31 23:03 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2016-03-31 23:03 UTC] danack@php.net
Please do performance measuring without xdebug enabled. There are no guarantees about performance when it is enabled.

Additionally, I'm unable to replicate what you are seeing, Running the test script on https://3v4l.org/kDYv3 gives consistently faster performance for PHP 7. Example values are:

Output for 7.0.5
Done in 0.048620939254761 seconds

Output for 5.6.19
Done in 0.078345060348511 seconds

Output for 5.5.33
Done in 0.065199851989746 seconds
 [2016-04-01 02:15 UTC] jacky at xsteach dot com
-Status: Feedback +Status: Closed
 [2016-04-01 02:15 UTC] jacky at xsteach dot com
Sorry for my mistake, thank you pointed out.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC