Go Premium for a chance to win a PS4. Enter to Win


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(); ?>

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

963 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