|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45247 45 times slower execution of PHP code snipet than with
Submitted: 2008-06-12 13:02 UTC Modified: 2008-06-12 13:25 UTC
From: itay dot malimovka at gmail dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.6 OS: Linux and Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: itay dot malimovka at gmail dot com
New email:
PHP Version: OS:


 [2008-06-12 13:02 UTC] itay dot malimovka at gmail dot com
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:
$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);

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)

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-12 13:25 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 18:01:33 2024 UTC