April 18, 2007

In the footer.php file in the K2 theme that came with the download you’ll find [include ‘db_profiling.php’] got commented out. I guess that is for bug hunting use. I have a look at the db_profiling.php file and if I’m not wrong that could be used to generate number of queries used and total time taken to execute queries as you normally see from footer of a typical WordPress site. Below is what I have done.

class metaHabari extends Theme
var $total_time_querying=0; # total time used to query
var $num_query=0; # number of query used
var $what_num; # para to pass to method
function get_no($what_num)
$profiles= DB::get_profiles();
foreach ($profiles as $profile) {
$total_time_querying+=$profile->total_time; }
$total_time_querying = number_format($total_time_querying,4,'.',',');
switch(strtolower($what_num)) {
case 'query': $no=$num_query;
case 'totaltime': $no=$total_time_querying;
case 'ver': $no=version::get_habariversion();
break; }
echo $no;

Insert the above into your theme.php file then call the method of this class metaHabari at your footer.

[?php metaHabari::get_no('totaltime'); ?]
seconds used in executing [?php metaHabari::get_no('query'); ?]
queries by version [?php metaHabari::get_no('ver'); ?]

The only issue I can see is that upon first loading of the posts.php you’ll get a funny large number of seconds used to execute queries, a second refresh gives a reasonable number. I also wondered why I’m getting version 0.1 displayed but in fact I’m using 0.1.1.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: