Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


speed of php5

Posted on 2006-07-21
Medium Priority
Last Modified: 2008-02-01
i am new to php5 and this is my first attempt of using it.

i am really just trying to find out if there are speed differences with php 5 and php 5.  also, does it (5) cache or something? i have noticed weird things in simple class which gets the contents of a directory and does things with it. when i run it the first time it takes 2-11 seconds. then if i refresh the page it will take .1 or less. is this normal? i would think php 5 would be faster.

i have error reporting set to e_all and have fixed anything it says.

also as an fyi: my server (shared environment) by default runs php 4 so you have to name files *.php5 to run under php5
Question by:qwertq
  • 4
  • 3
LVL 14

Expert Comment

ID: 17159528
Not that i'm aware of. If you script is messing file files, it is more probable that your operating system is doing cache.

Have you ever tried on a linux box something like "grep" or "ls" on a busy directory? The first time it take much time, the second time it is faster...

Author Comment

ID: 17160262
can you comment on the speed of php5 vs php4? are there differences?

these two pages are the exact same code. i wrote it for 5, but also saved a duplicate for 4. notice the difference in load time (bottom of page) for the two identical pages. this makes me think it is 5 running slow.

LVL 14

Expert Comment

ID: 17161111
it makes no sense such benchmark.. in fact loading the two pages shows different loading times each time. Sometimes .php version is faster than .php5, other times it's the opposite.

anyway, as i suspect that they are both the same php version.. can you add this at the top of them?
<?php print phpversion(); ?>
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 17161257
added. they are different versions. my host runs php 5 under cgi. do you think this could be a cause of the slowness?

i understand the page loads will change somewhat, but i have pretty consistantly been able to confirm the php5 page runs about twice as slow. sometimes more.
LVL 14

Accepted Solution

ThG earned 500 total points
ID: 17161656
you are right, it definitely looks that on the avarage the php4 version runs faster.

unfortunately i think i won't be able to help you. I don't know in detail internal Zend2 changes respect Zend1. Maybe if you don't mind posting the source code, we might track down a particular construct or system call that is causing this.

this would be anyway a step-by-step procedure, benchmarking each block of code with some loops.

Author Comment

ID: 17162996
I just got this back from my isp:

"Yes, the slow performance will be caused by running PHP 5 as a CGI.

Unfortunately as of right now we have no plans of upgrading the version of PHP on our shared servers.

If you wish, you may compile your own version of PHP under your account (which we cannot offer any assistance doing) or you may choose to upgrade your account to a dedicated QS hosting package:"

Sucks.... man they need to get with it. Php5 has been out a while. Thanks for the help.
LVL 14

Expert Comment

ID: 17163814
yuck.. did you mention that *only* php5 was ran under CGI? of course, if php4 is ran as apache module it's way faster.. it doesn't have the overhead of spawning another process and computing lots of I/O for each request.

i assumed that both were CGI..

nice to know then, it wasn't nice to know that Zend2 is faster than Zend1.


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question