Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created March 17, 2016 18:18
Show Gist options
  • Save lgedeon/a10187d73149f2d1ff50 to your computer and use it in GitHub Desktop.
Save lgedeon/a10187d73149f2d1ff50 to your computer and use it in GitHub Desktop.
Rough code to help find long running processes
<?php
function time_the_hooks( $hook = null ) {
static $time = array( 0, '', array() );
if ( in_array( $hook, array('gettext') ) ) { return; }
ob_clean();
// if ( microtime(true) - $time[0] > 0.0001 ) {
if ( 'get_' === $time[1] ) {
echo (int) ( ( microtime( true ) - $time[0] ) * 100000 );
echo ' &nbsp; &nbsp; ' . $time[1];
echo "<br>\n";
var_export($time[2]);
echo "<br>\n";
}
$time = array( microtime(true), $hook, func_get_args() );
ob_flush();
}
add_action( 'all', 'time_the_hooks' );
ob_start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment