Results 1 to 12 of 12
Thread: PHP5 slow?
-
07-04-2005, 02:33 PM #1Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
PHP5 slow?
hi,
I was running some stats on php speed this morning, via shell. And it seems to be really slow. I wrote a small script with the following code:
PHP Code:#!/usr/bin/php
<?php
for ($i = 0; $i < 100; ++$i) echo("Hello!\n");
?>
real 0m0.463s
By the way a friend tested such a script on his server with php4, and it took 0.036 seconds.
And in perl on my server it took 0.014 seconds.
So the speed given seems to be rediculous. Any ideas?
-
07-04-2005, 03:48 PM #2Junior Guru Wannabe
- Join Date
- Jun 2005
- Posts
- 46
I think your test is to simple and you didn't have the same conditions for php4. Check this link for more info.
http://www.sourcelabs.com/SourceLabsPHP4vsPHP5.pdfIn summary, PHP5 consistently performed better than PHP4. This performance increase varied between being equal in performance to having a performance increase as large as 20.49%. In several test cases, however, PHP4 performed better than PHP5. In one test case testing the function “preg_match” PHP4 performed 29.37% better than PHP5.
-
07-04-2005, 03:54 PM #3Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
Hi,
The code executed on the php4 server was exactly the same as what I executed. Regardless, it is rediculous that such a script should take 463 milliseconds to execute. This is not just in one case, I've executed it multiple times and have come out with similar results.
Let me run it five times right now and give all five results.
- 0.419
- 0.768
- 0.386
- 0.731
- 0.235s
And the server load is 0.14.
-
07-04-2005, 04:14 PM #4Junior Guru Wannabe
- Join Date
- Jun 2005
- Posts
- 46
The code was the same but it was on a different machine. You need the same conditions.
The typical php script has some mysql queries (where it spends 90% of its time) and maybe some regex stuff. The script is used inside apache where the php module is already loaded.
If you are satisfied with php4, there is no great need to change. I use php5 for my sites and I didn't notice any problem.
-
07-04-2005, 04:17 PM #5Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
Oh we already use php5, I was just quite disturbed by those stats.
Brandon
-
07-04-2005, 04:28 PM #6Junior Guru Wannabe
- Join Date
- Jun 2005
- Posts
- 46
Try this: (you don't count the loading time for php)
PHP Code:#!/usr/bin/php
<?php
$start=microtime(TRUE);
for ($i = 0; $i < 100; ++$i) echo("Hello!\n");
$end=microtime(TRUE);
$dif=$end-$start;
echo "Loop time: $dif\n";
?>
-
07-05-2005, 08:19 AM #7Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
hi,
Yeah, with that code it takes about 110 milliseconds.
Lol, I don't get your comment about the server load?
-
07-08-2005, 08:09 AM #8Web Hosting Evangelist
- Join Date
- Mar 2004
- Location
- New Zealand
- Posts
- 532
Are you testing both PHP4 and PHP5 execution in the same way? Sounds to me like you are testing PHP5 on the cli and PHP4 as an apache module, so of course the PHP5 test would be slower!
-
07-08-2005, 08:30 AM #9Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
i,
No, I'm testing php5 as an apache module.
Anyway I've let this issue go.
-
07-08-2005, 04:12 PM #10Junior Guru Wannabe
- Join Date
- Oct 2004
- Location
- Florida
- Posts
- 42
what they are saying is that the conditions need to be the same , it needs to be the same exact code , running on the same exact server , in the same manner. everything will effect this , versions of apache, server specs , the load the server was under, all of these things need to be factored in.
~ PHPConcepts Owner
==========================
http://www.phpconcepts.com
-
07-08-2005, 06:48 PM #11Web Hosting Master
- Join Date
- Jun 2004
- Location
- Bay Area -USA
- Posts
- 1,740
Also if it's a shared server, the server load changes. Maybe you tested it in a time when the load was at a high?
<<< Please see Forum Guidelines for signature setup. >>>
-
07-08-2005, 06:52 PM #12Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
hi,
It may be, I hadn't checked the number of connections at the time. Load was pretty low though, around 0.1.
I'm not going to worry about it though. A friend ran it on a server with similar specks with php4, and it ran about the same.