Page 1 of 1

Site running slow... pls help

Posted: Mon Apr 07, 2008 2:31 pm
by laics
Dear all,

I have just uploaded my files to hostinghogator. However then only i realise that my code is running really slow when i access to my page. The execution delayed each time it encountered to functions which are to retrieve and display info. Can you please advice me any method to make my php scripts run faster? it took nearly 30 sec to load my home page eventhough I have apply gzip compression, javascript compression.. Please advice...
Thanks..

Re: Site running slow... pls help

Posted: Mon Apr 07, 2008 2:43 pm
by pickle
We're going to need to know WAAAAYY more before we can tell you how to optimize your scripts.

The best way you can do it yourself is to put: echo microtime() all throughout your scripts. This will echo the current time with microseconds to the screen. Examining this output can help you figure out which parts of your scripts are running slow.

Re: Site running slow... pls help

Posted: Mon Apr 07, 2008 2:48 pm
by arjan.top
xdebug profiling is the way to go

http://xdebug.org/docs/profiler

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 1:35 am
by matthijs
Have you tested your code locally? That way you know if it's the server or not. Sometimes (shared) servers can be very slow. There are huge differences between hosting providers.

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 1:47 am
by laics
Dear matthijs, thanks for the reply. I have tested the code locally and it just work fine. It is since I uploaded my code to the server then only I encountered such a slow speed. This is the reason I am trying to change some of my initial code and see whether there's improvement. Any comment? Tq..

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 1:56 am
by matthijs
Ok, then it is possible that it's just the server of the host. If you have access to other hosting you could try that.

I have just cancelled a Dreamhost account because the server was so slow.

And, as others suggested, you can test your code with xDebug or microtime. If you know it runs fast locally, it must be the server. And optimizing the code doesn't make sense then.

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 2:14 am
by laics
Is it possible to run xDebug on shared host? If can may I know how to do so? thanks

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 2:23 am
by arjan.top
why would you do that?

Parts of the code that are slow are slow on localhost too

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 2:40 am
by matthijs
If your code runs in 0.4 seconds locally, and it takes 30 seconds to load your page on the host, it will not change anything if you manage to change your code to run in .35 seconds.

Re: Site running slow... pls help

Posted: Tue Apr 08, 2008 2:45 am
by arjan.top
Damn missed the post that script works fine locally

Then yes, find another host :D