php slowing my site?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
doron447
Forum Newbie
Posts: 4
Joined: Sat Jan 24, 2009 7:24 am

php slowing my site?

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: php slowing my site?

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: php slowing my site?

Post 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 :).
doron447
Forum Newbie
Posts: 4
Joined: Sat Jan 24, 2009 7:24 am

Re: php slowing my site?

Post 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
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: php slowing my site?

Post 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?
doron447
Forum Newbie
Posts: 4
Joined: Sat Jan 24, 2009 7:24 am

Re: php slowing my site?

Post 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
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: php slowing my site?

Post by Mirge »

Can you provide a URL so we can see first-hand which pages are slow?
Post Reply