Last active
November 29, 2016 23:08
-
-
Save brianjhanson/52dae4616a197911d415e7867ccd806b to your computer and use it in GitHub Desktop.
More useful output of craft profiling console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
/*<![CDATA[*/ | |
if (typeof(console) == 'object' && typeof console.groupCollapsed == 'function') | |
{ | |
console.groupCollapsed("Profiling Summary Report"); | |
console.log("Time: <?php echo sprintf('%0.5f', Craft\Craft::getLogger()->getExecutionTime()); ?>s\n"); | |
console.log("Memory: <?php echo number_format(Craft\Craft::getLogger()->getMemoryUsage() / 1024); ?>Kb\n"); | |
console.log("Total Queries: <?php echo is_array($data) ? count($data) : '0'; ?>\n"); | |
<?php | |
$queries = []; | |
foreach ($data as $index => $entry) | |
{ | |
$proc = CJavaScript::quote($entry[0]); | |
$count = sprintf('%5d',$entry[1]); | |
$min = sprintf('%.5f',$entry[2]); | |
$max = sprintf('%.5f',$entry[3]); | |
$total = sprintf('%.5f',$entry[4]); | |
$average = sprintf('%.5f',$entry[4]/$entry[1]); | |
$queries[] = [ | |
'count' => $count, | |
'min' => $min, | |
'max' => $max, | |
'total' => $total, | |
'average' => $average, | |
'proc' => $proc | |
]; | |
} | |
?> | |
console.table(<?php echo json_encode($queries, JSON_NUMERIC_CHECK); ?>); | |
console.groupEnd(); | |
} | |
/*]]>*/ | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace the
profile-summary-firebug.php
file incraft/app/templates/logging
with this for some sweet, sweetconsole.table
output.