Bug #73678 [NEW]: Strange performance degradation

From: Date: Wed, 07 Dec 2016 19:39:46 +0000
Subject: Bug #73678 [NEW]: Strange performance degradation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205827@lists.php.net to get a copy of this message
From: riggsfolly at gmail dot com Operating system: Windows PHP version: 7.1.0 Package: Performance problem Bug Type: Bug Bug description:Strange performance degradation Description: ------------ I was using this script to benchmark a question on StackOverflow and I noticed that in PHP 7.1.0 the creation of a stdClass() object increased in time taken by an appreciable amount between PHP7.0.13 and PHP7.1.0 This seemed rather odd based on all the speed improvment work done in 7.0 and 7.1 so I thought I would report it, in case it pointed someone at something that may have changed in 7.1 to the damage a speed improvement. Results for different versions of PHP PHP7.1.0 Using (object) [] method 10,000,000 times 22.970033168793 Using new stdClass() method 10,000,000 times 38.114390850067 Difference (-ve) means (object) [] is quicker -15.144357681274 PHP7.0.13 Using (object) [] method 10,000,000 times 22.230031967163 Using new stdClass() method 10,000,000 times 29.300040960312 Difference (-ve) means (object) [] is quicker -7.0700089931488 PHP5.6.25 Using (object) [] method 10,000,000 times 47.920066833496 Using new stdClass() method 10,000,000 times 54.20007610321 Difference (-ve) means (object) [] is quicker -6.2800092697144 PHP5.5.36 Using (object) [] method 10,000,000 times 46.450064897537 Using new stdClass() method 10,000,000 times 53.110074043274 Difference (-ve) means (object) [] is quicker -6.6600091457367 Test script: --------------- function one() { $obj = (object) ['prop1' => 1, 'prop2' => 2]; return $obj; } function two() { $obj = new stdClass(); $obj->prop1 = 1; $obj->prop2 = 2; return $obj; } $looper = 10000000; $a = microtime(1); for ( $i=0; $i < $looper; $i++) { $x = one(); } $b = microtime(1); $c = $b-$a; echo "Using (object) [] method $looper times " . $c . PHP_EOL; $a = microtime(1); for ( $i=0; $i < $looper; $i++) { $x = two(); } $b = microtime(1); $d = $b-$a; echo "Using new stdClass() method $looper times " . $d . PHP_EOL; echo 'Difference (-ve) means (object) [] is quicker ' . ($c - $d) . PHP_EOL; -- Edit bug report at https://bugs.php.net/bug.php?id=73678&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73678&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73678&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73678&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73678&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73678&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73678&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73678&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73678&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73678&r=support Expected behavior: https://bugs.php.net/fix.php?id=73678&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73678&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73678&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73678&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73678&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73678&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73678&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73678&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73678&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73678&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73678&r=mysqlcfg

« previous php.bugs (#205827) next »