Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created June 25, 2014 09:51
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 kovshenin/5f621795e7c67a751929 to your computer and use it in GitHub Desktop.
Save kovshenin/5f621795e7c67a751929 to your computer and use it in GitHub Desktop.
<?php
$XHPROF_ROOT = '/home/kovshenin/xhprof';
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
add_action( 'init', function() {
// Make sure it's in cache before we profile.
$post = get_post( $post_id );
$post_id = 1134;
xhprof_enable();
for ( $i = 0; $i < 1000; $i++ ) {
profile_get_permalink_with_obj( $post_id );
profile_get_permalink_with_id( $post_id );
}
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");
?>
<iframe src="<?php echo "http://prof.lo/index.php?run=$run_id&source=xhprof_foo"; ?>" width="100%" height="800" />
<?php die();
} );
function profile_get_permalink_with_obj( $post_id ) {
get_permalink( $post_id, false, true );
}
function profile_get_permalink_with_id( $post_id ) {
get_permalink( $post_id, false, false );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment