473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

PHP Optimization question

I'm trying to optimize a php project of mine and I'm running into some
problems.

Overall the page takes about .4-.5 seconds to render (just the code,
i'm recording the time at start and finish of execution) on a my dual
core server with nothing else running (other than httpd and mysqld)

I've optimized my queries, total mysql query time is about .1 to .12
seconds total.

For some reason the part of my php that takes the longest to execute
is a rather large section of html code with some <? echo $someVar; ?>
sprinkled in. There is no logic or functional calls, yet this block
of code (maybe 50 lines of HTML, takes around .3 seconds to execute.

Can anyone recomend ways to find out where my php code is executing
slow?

Thank you
Jan 13 '08 #1
8 1290
On Jan 12, 10:42 pm, IanRear...@gmail.com wrote:
I'm trying to optimize a php project of mine and I'm running into some
problems.

Overall the page takes about .4-.5 seconds to render (just the code,
i'm recording the time at start and finish of execution) on a my dual
core server with nothing else running (other than httpd and mysqld)

I've optimized my queries, total mysql query time is about .1 to .12
seconds total.

For some reason the part of my php that takes the longest to execute
is a rather large section of html code with some <? echo $someVar; ?>
sprinkled in. There is no logic or functional calls, yet this block
of code (maybe 50 lines of HTML, takes around .3 seconds to execute.

Can anyone recomend ways to find out where my php code is executing
slow?

Thank you
is it your local machine? or hosting..its maybe the bandwidth, or
maybe you have internet protection. that scan the internet content
before it render the code.
Jan 13 '08 #2
On 13 Jan, 08:06, "radmissio...@gmail.com" <radmissio...@gmail.com>
wrote:
On Jan 12, 10:42 pm, IanRear...@gmail.com wrote:
I'm trying to optimize a php project of mine and I'm running into some
problems.
Overall the page takes about .4-.5 seconds to render (just the code,
i'm recording the time at start and finish of execution) on a my dual
core server with nothing else running (other than httpd and mysqld)
I've optimized my queries, total mysql query time is about .1 to .12
seconds total.
For some reason the part of my php that takes the longest to execute
is a rather large section of html code with some <? echo $someVar; ?>
sprinkled in. There is no logic or functional calls, yet this block
of code (maybe 50 lines of HTML, takes around .3 seconds to execute.
Can anyone recomend ways to find out where my php code is executing
slow?
Thank you

is it your local machine? or hosting..its maybe the bandwidth, or
maybe you have internet protection. that scan the internet content
before it render the code.
Unlikely to be a bandwidth problem unless the geenrated page is very
large and being flushed intermittently to the browser.

Sounds like a job for XDebug + Kcachegrind

C.
Jan 13 '08 #3
On 13 Jan., 07:42, IanRear...@gmail.com wrote:
>
I've optimized my queries, total mysql query time is about .1 to .12
seconds total.
Although mySQL takes just a few seconds, did you use an index for
attributes
in WHERE clauses?

Additionally, MySQL disables its cache by default. You need to enable
it
manually to make MySQL return cached result sets.

Moreover, note that MySQL only assumes queries to be identical, if
they are textually identical. Even a a single added space make MySQL
compute the query again and no use the cache.
Jan 13 '08 #4
Ia********@gmail.com wrote:
I'm trying to optimize a php project of mine and I'm running into some
problems.

Overall the page takes about .4-.5 seconds to render (just the code,
i'm recording the time at start and finish of execution) on a my dual
core server with nothing else running (other than httpd and mysqld)

I've optimized my queries, total mysql query time is about .1 to .12
seconds total.

For some reason the part of my php that takes the longest to execute
is a rather large section of html code with some <? echo $someVar; ?>
sprinkled in. There is no logic or functional calls, yet this block
of code (maybe 50 lines of HTML, takes around .3 seconds to execute.

Can anyone recomend ways to find out where my php code is executing
slow?

Thank you
How do you know it's taking that long for the PHP to execute? I
wouldn't expect it to take very long to process the HTML code. You
didn't show us what echo statements you had, but I wouldn't expect a few
of those to take long, either.

There can be a lot of other things involved. For instance, during this
code, you may have filled the PHP buffers. This would have flushed the
buffers to your web server.

Now, flushing the PHP buffers to the web server could easily have filled
the web servers buffer. So now the web server has to flush its buffers
to the browser.

All of this takes time, also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 13 '08 #5
My sever is a dual core intel box, dedicated running CentOS and 1 gig
of ram. No other websites are hosted on this box

I have MySQL query cache of about 100M, which is being used quite a
bit when I check the cache hits

The php code is just HTML with inline php statements like, probably
about 75-100 lines
(this is just an example, my page uses CSS not tables)
<table>
<tr>
<td><? echo $someVar; ?></td>
</tr>
</table>
To check the execution time I use a fucntion as follows

function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}

I record the start time, and end time, then print the delta

Any other suggestions would be appreciated, thank you!

On Jan 13, 9:13 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
IanRear...@gmail.com wrote:
I'm trying to optimize a php project of mine and I'm running into some
problems.
Overall the page takes about .4-.5 seconds to render (just the code,
i'm recording the time at start and finish of execution) on a my dual
core server with nothing else running (other than httpd and mysqld)
I've optimized my queries, total mysql query time is about .1 to .12
seconds total.
For some reason the part of my php that takes the longest to execute
is a rather large section of html code with some <? echo $someVar; ?>
sprinkled in. There is no logic or functional calls, yet this block
of code (maybe 50 lines of HTML, takes around .3 seconds to execute.
Can anyone recomend ways to find out where my php code is executing
slow?
Thank you

How do you know it's taking that long for the PHP to execute? I
wouldn't expect it to take very long to process the HTML code. You
didn't show us what echo statements you had, but I wouldn't expect a few
of those to take long, either.

There can be a lot of other things involved. For instance, during this
code, you may have filled the PHP buffers. This would have flushed the
buffers to your web server.

Now, flushing the PHP buffers to the web server could easily have filled
the web servers buffer. So now the web server has to flush its buffers
to the browser.

All of this takes time, also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Jan 13 '08 #6
On 13 Jan., 17:34, IanRear...@gmail.com wrote:
I have MySQL query cache of about 100M, which is being used quite a
bit when I check the cache hits
Could you provide the whole script. I don't see anything special which
would
force the web-app to answer slow yet.

The actual source might help.
Jan 13 '08 #7
On Sat, 12 Jan 2008 22:42:11 -0800 (PST), in comp.lang.php
Ia********@gmail.com
<08**********************************@f47g2000hsd. googlegroups.com>
wrote:
>| I'm trying to optimize a php project of mine and I'm running into some
| problems.
|
| Overall the page takes about .4-.5 seconds to render (just the code,
| i'm recording the time at start and finish of execution) on a my dual
| core server with nothing else running (other than httpd and mysqld)
|
| I've optimized my queries, total mysql query time is about .1 to .12
| seconds total.
|
| For some reason the part of my php that takes the longest to execute
| is a rather large section of html code with some <? echo $someVar; ?>
| sprinkled in. There is no logic or functional calls, yet this block
| of code (maybe 50 lines of HTML, takes around .3 seconds to execute.
|
| Can anyone recomend ways to find out where my php code is executing
| slow?
|
| Thank you
You're joking, right?
Have you stopped to think that it might not be the php code that is
slowing things down?
In another post you show a simple table layout.
Could it be your browser that is causing this 'bottleneck'?
The browser needs to :
read your generated code
parse it
create the DOM structure
render the table

No of the above happens until the </tabletag is reached.

To test this out:
remove all html code from the page and just have your echo statements.
What is the timing?
-- -------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Jan 13 '08 #8
IanReardon wrote:
Overall the page takes about .4-.5 seconds to render (just the code, i'm
recording the time at start and finish of execution) on a my dual core
server with nothing else running (other than httpd and mysqld)
Have you tried running your script from the command line? It may be that
the bottleneck is in Apache, not your script.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 15 days, 23:10.]

GPS & Cameras
http://tobyinkster.co.uk/blog/2008/01/14/gps-cameras/
Jan 15 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick L. | last post by:
All, This is a general question regarding how, and if, compiler optimization techniques affect the general concept of being able to update a component of an application without requiring a...
20
by: Jakob Bieling | last post by:
Hi! I am using VC++ 7.1 and have a question about return value optimization. Consider the following code: #include <list> #include <string> struct test {
5
by: AC Slater | last post by:
Whats the simplest way to change a single stored procedures query optimization level? In UDB8 that is. /F
14
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
93
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the...
22
by: NigelW | last post by:
This is really a question for the development team. Are there plans to improve the optimization of C# to MSIL? I ask this, as inspection with ILDASM of the MSIL code shows that, even with the...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
0
by: Adam Sandler | last post by:
Hello, Using VWD 2005 here... I've noticed I've got .NET services on my system here: the .NET Runtime Optimization service and ASP.NET State service. I've noticed when the ASP.NET State service...
18
by: terminator(jam) | last post by:
consider: struct memory_pig{//a really large type: memory_pig(){ std::cout<<"mem pig default\n"; //etc... }; memory_pig(memory_pig const&){
20
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.