From: itay dot malimovka at gmail dot com Operating system: Linux and Windows PHP version: 5.2.6 PHP Bug Type: Performance problem Bug description: 45 times slower execution of PHP code snipet than with asp.net
Description: ------------ the following code is run ~45 times slower compared to a similar C# code. I run the test on several machines (32 & 64, Windows and Linux-on linux only the PHP). Notice in the example below I give both PHP and C# codes I used. Reproduce code: --------------- //PHP //---------------------------------------------------------------------------------------------------------------- <?php set_time_limit(0); $start=time(); $arr = array(1,2,3,4,5,6,7,8,9,0); $x = 8; for ($i=0;$i<94707441;$i++) { $x = $arr[$i%10]; $y = $arr[$i%7]; if ($x == $y) { $total += $x*$y; //$words .= ','.$x; } } echo $total."<Br>"; echo "total time : ".(time()-$start); ?> //C# //---------------------------------------------------------------------------------------------------------------- int startTime = Environment.TickCount; int[] arr; arr = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; int x = 8; int y=0; int total=0; for (int i = 0; i < 94707441; i++) { x = arr[i%10]; y = arr[i%7]; if(x == y) total+=x*y; } Response.Write(total+"<br>"); int endTime = Environment.TickCount; double executionTime = (double)(endTime - startTime) / 1000.0; Response.Write("Page Execution time is " + executionTime + " seconds."); Expected result: ---------------- at least execution time should be the same. Actual result: -------------- php runs much much slower X45 that asp.net -- Edit bug report at http://bugs.php.net/?id=45247&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45247&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45247&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45247&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45247&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45247&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45247&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45247&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45247&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45247&r=support Expected behavior: http://bugs.php.net/fix.php?id=45247&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45247&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45247&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45247&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45247&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45247&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45247&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45247&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45247&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45247&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45247&r=mysqlcfg