Skip to content

Instantly share code, notes, and snippets.

@pj-dave
Created November 18, 2016 11:25
Show Gist options
  • Save pj-dave/c258e755722c16c4ff982cb1bb2382c7 to your computer and use it in GitHub Desktop.
Save pj-dave/c258e755722c16c4ff982cb1bb2382c7 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