Skip to content

Instantly share code, notes, and snippets.

@ericmann
Created November 25, 2014 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericmann/296897ca4195afe4eca5 to your computer and use it in GitHub Desktop.
Save ericmann/296897ca4195afe4eca5 to your computer and use it in GitHub Desktop.
<?php
$query_timer = 0;
add_filter( 'do_parse_request', function( $parse ) {
global $query_timer;
$query_timer = microtime( true );
return $parse;
} );
add_action( 'parse_request', function() {
global $query_timer;
$time = microtime( true ) - $query_timer;
add_action( 'wp_head', function() use ( $time ) {
echo '<!-- timer: ' . $time . ' -->';
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment