What is considered a long execution time?

Stephen Watkins picture Stephen Watkins · Mar 14, 2010 · Viewed 10k times · Source

I am trying to figure out the efficiency of my server side code.

Using microtime(true) to measure speed, I am able to calculate the time it took my script to run.

I am getting average speeds of .3 to .5 seconds. These scripts do a number of database queries to return different values to the user.

What is considered an efficient execution time for PHP scripts that will be run online for a website?

I know it depends on exactly what is being done, but just consider this a standard script that reads from a database and returns values to the user. I look at Google and see them search the internet in .15 seconds and I feel like my script is crap.

Answer

Andy picture Andy · Mar 14, 2010

YouTube's target page rendering time is < 100ms (Video here @7:00).

Your bottleneck is probably DB queries - try using

EXPLAIN select * from x...

to see if you can add indexes that will speed up your queries.

edit the link above has died. High Scalability did a feature on YouTube that used that video as its primary source, so it may be of some interest: http://highscalability.com/youtube-architecture