I am using the MySQL server profiling function (from 5.0.37).
<?php
$set_profiling = $mysqli->query( 'SET profiling = 1' );
$result1 = $mysqli->query( 'SELECT DESTINATIONCODE, ZONENAME FROM ZONES' );
$result2 = $mysqli->query( 'SELECT ZONENAME FROM ZONES' );
$show_profiles = $mysqli->query( 'SHOW PROFILES' );
while( $row = $show_profiles->fetch_assoc() ) {
echo '<pre>';
print_r( $row );
echo '</pre>'
}
In addition, if you want to get a more detailed report after each request that you can use:
$show_profile = $mysqli->query( 'SHOW PROFILE' );
Check http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html .
This is a bit raw visualization, but it works.
Output Example:
Array
(
[Query_ID] => 1
[Duration] => 0.00012000
[Query] => SELECT DESTINATIONCODE, ZONENAME FROM ZONES
)
Array
(
[Query_ID] => 2
[Duration] => 0.00006800
[Query] => SELECT ZONENAME FROM ZONES
)
# 1:
Array
(
[Status] => (initialization)
[Duration] => 0.000002
)
Array
(
[Status] => checking query cache for query
[Duration] => 0.000003
)
Array
(
[Status] => checking privileges on cached
[Duration] => 0.000002
)
Array
(
[Status] => checking permissions
[Duration] => 0.000001
)
Array
(
[Status] => sending cached result to clien
[Duration] => 0.000056
)
Array
(
[Status] => logging slow query
[Duration] => 0.000001
)