Here’s a little bit of code to display the percent of a page’s generation time used by PHP and MySQL.

First, add this into your theme’s functions.php file so that data about each MySQL query is stored, namely the time taken.

<?php define( 'SAVEQUERIES', true ); ?>

Then in your footer.php, use this code to display it: (click the Copy icon to view the unformatted code)

<?php

global $wpdb;

// Get the total page generation time
$totaltime = timer_stop( false, 22 );

// Calculate the time spent on MySQL queries by adding up the time spent on each query
$mysqltime = 0;
foreach ( $wpdb->queries as $query )
	$mysqltime = $mysqltime + $query[1];

// The time spent on PHP is the remainder
$phptime = $totaltime - $mysqltime;

// Create the percentages
$mysqlper = number_format_i18n( $mysqltime / $totaltime * 100, 2 );
$phpper   = number_format_i18n( $phptime / $totaltime * 100, 2 );

// Output the stats
echo 'Page generated in ' . number_format_i18n( $totaltime, 5 ) . " seconds ( {$phpper}% PHP, {$mysqlper}% MySQL )";

?>

That will output code something like this: Page generated in 0.24691 seconds ( 95.50% PHP, 4.50% MySQL )