Created
March 17, 2016 18:18
-
-
Save lgedeon/a10187d73149f2d1ff50 to your computer and use it in GitHub Desktop.
Rough code to help find long running processes
This file contains hidden or 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
<?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 ' ' . $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