|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-06-12 13:25 UTC] mgf@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
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