Caching added on Sellstuff.co.za

I have added code to cache the title's and other potions of ads on www.sellstuff.co.za.

Before I did this though I added a small section at the bottom of the pages on the site to show how long the code ran for and how many queries were executed to generate the page. The difference in the number of queries run has been substantial, the total execution time has also been affected but not quite as drastically.

I work out the time with the following bits of code;

This is added in the file I am calling

PHP:
  1. $mtime = microtime();
  2. $mtime = explode(" ",$mtime);
  3. $mtime = $mtime[1] + $mtime[0];
  4. $starttime = $mtime;

and then in my footer I have the following bit of code

PHP:
  1. global $starttime;
  2. $mtime = microtime();
  3. $mtime = explode(" ",$mtime);
  4. $mtime = $mtime[1] + $mtime[0];
  5. $endtime = $mtime;
  6. $totaltime = ($endtime - $starttime);

I then just disply $totaltime in the footer. Easy hey!

Posted under Classifeds Sites Updates, PHP Web Development

This post was written by Shaun on November 25, 2009

Tags: , ,

Leave a Comment

Name (required)

Email (required)

Website

Comments

More Blog Post

Previous Post: