Skip to content

Instantly share code, notes, and snippets.

@whaleinvasion
Forked from pj-dave/pj-profiling.php
Created December 20, 2016 10:07
Show Gist options
  • Save whaleinvasion/a0167a0f4caeee99ffd5af025e1defdb to your computer and use it in GitHub Desktop.
Save whaleinvasion/a0167a0f4caeee99ffd5af025e1defdb to your computer and use it in GitHub Desktop.
<?php
/** XHProf configuration */
if ( isset( $_REQUEST['pressjitsu-profile'] ) && $_REQUEST['pressjitsu-profile'] == 'enable' ) {
xhprof_enable( XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU );
ob_start();
register_shutdown_function( function() {
ob_end_clean();
header( 'Content-type: application/octet-stream' );
header( sprintf( 'Content-Disposition: attachment; filename="%d.perf.xhprof"', time() ) );
echo serialize( xhprof_disable() );
exit;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment