Page 1 of 1

php slowing my site?

Posted: Mon Oct 26, 2009 12:51 pm
by doron447
Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is very big.
maybe in some cases there are un-optimal functions, I mean functions that I can improve them to get optimal performance.

Is there a way to know how much time takes to run parts of the code?
Is there any way to know what is the speed of regular-build functions such as: array_rand, copy array.. etc.. ?
How can I know what is the main reason inside the code that slowing my site??

Thanks,
Doron

Re: php slowing my site?

Posted: Mon Oct 26, 2009 1:46 pm
by pickle
There may be automatic or more fancy ways of doing it, but when I'm looking to find what's taking a long time, I output microtime() throughout the code.

Re: php slowing my site?

Posted: Mon Oct 26, 2009 2:34 pm
by Mirge
doron447 wrote:Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is very big.
maybe in some cases there are un-optimal functions, I mean functions that I can improve them to get optimal performance.

Is there a way to know how much time takes to run parts of the code?
Is there any way to know what is the speed of regular-build functions such as: array_rand, copy array.. etc.. ?
How can I know what is the main reason inside the code that slowing my site??

Thanks,
Doron
Narrow down specifically what pages are considered "slow"... then benchmark those pages, various parts of the scripts... until you figure out what your bottleneck is. Are you using MySQL for anything? That can be a bottleneck with large databases that aren't utilizing INDEXES, etc... or it could be your code itself being inefficient.

Figure out what pages are being slow, then do as pickle suggested :).

Re: php slowing my site?

Posted: Fri Oct 30, 2009 7:01 am
by doron447
Thank you pickle, thank you mirge,

Yes, I'm using MYSQL, the queries are not so comlicated.
When I'm using the site on local host the speed is high.

Doron

Re: php slowing my site?

Posted: Fri Oct 30, 2009 10:37 am
by Mirge
doron447 wrote:Thank you pickle, thank you mirge,

Yes, I'm using MYSQL, the queries are not so comlicated.
When I'm using the site on local host the speed is high.

Doron
Hmm.. do you have big images? Not big dimension-wise... but big in file size?

Re: php slowing my site?

Posted: Fri Nov 06, 2009 4:34 am
by doron447
Hi,

Thank you Mirge for your answer.

No, the images are not big, 5kb X 5 pictures. they are placed all over the screen and in the CSS I strech & shrink them (maybe its taking more time?)

another thing that I'm suspecting thats the problem:
the site showing the same page in with a diffrent content (using "get", for ex: one time is showing index.php?a=1&b=2, and in the other time showing: index.php?a=4&b=7) and all the time it is changing.
maybe in that way the cookies are not working good? cuz they are working on absule address?

Doron

Re: php slowing my site?

Posted: Fri Nov 06, 2009 9:58 am
by Mirge
Can you provide a URL so we can see first-hand which pages are slow?