Skip to content

Instantly share code, notes, and snippets.

@brianjhanson
Last active November 29, 2016 23:08
Show Gist options
  • Save brianjhanson/52dae4616a197911d415e7867ccd806b to your computer and use it in GitHub Desktop.
Save brianjhanson/52dae4616a197911d415e7867ccd806b to your computer and use it in GitHub Desktop.
More useful output of craft profiling console
<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>
@brianjhanson
Copy link
Author

Replace the profile-summary-firebug.php file in craft/app/templates/logging with this for some sweet, sweet console.table output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment