ID: 45247 Updated by: [EMAIL PROTECTED] Reported By: itay dot malimovka at gmail dot com -Status: Open +Status: Bogus Bug Type: Performance problem Operating System: Linux and Windows PHP Version: 5.2.6 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Order-of-magnitude differences in execution times are ro be expected when comparing a compiled language with an interpreted one. Try comparing PHP with other interpreted languages such as perl, Ruby, Python, etc. Previous Comments: ------------------------------------------------------------------------ [2008-06-12 13:02:58] itay dot malimovka at gmail dot com 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 this bug report at http://bugs.php.net/?id=45247&edit=1