The Daily WTF
Loading times for web pages is one of the key metrics we like to tune. Users will put up with a lot if they feel like they application is responsive. So when Caivs was handed 20MB of PHP and told, “one of the key pages takes like 30-45 seconds to load. Figure out why,” it was at least a clear goal.
Combing through that gigantic pile of code to try and understand what was happening was an uphill battle. Eventually, Caivs just decided to check the traffic logs while running the application. That highlighted a huge spike in traffic every time the page loaded, and that helped Caivs narrow down exactly where the problem was.
$first_image = ”; foreach($images as $the_image) { $image = $the_image[‘url’]; if(file_exists($config->base_url.’/uploads/’.$image)) { if($first_image==”) { $first_image = $image; } $image_dimensions = ‘&w=648&h=432’; $get_dimensions = getimagesize(‘http://old.datacenter.ip.address/’.$config->base_url.’/uploads/’.$image); if($get_dimensions[0] < $get_dimensions[1]) $image_dimensions = ‘&h=432’; echo ‘<li>’.$config->base_url.’/timthumb.php?src=’.$config->base_url.’/uploads/’.$image.’&w=125&h=80&zc=1′), ‘javascript:;’, array(‘onclick’=>’$(‘.image_gallery .feature
To read the full article click on the 'post' link at the top.