Created
February 11, 2012 09:50
-
-
Save masudak/1798332 to your computer and use it in GitHub Desktop.
embedding xhprof
This file contains 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
// start profiling | |
xhprof_enable(); | |
// ここからWPのコード | |
/** | |
* Tells WordPress to load the WordPress theme and output it. | |
* | |
* @var bool | |
*/ | |
define('WP_USE_THEMES', true); | |
/** Loads the WordPress Environment and Template */ | |
require('./wp-blog-header.php'); | |
// ここまでWPのコード | |
// stop profiler | |
$xhprof_data = xhprof_disable(); | |
// display raw xhprof data for the profiler run | |
print_r($xhprof_data); | |
$XHPROF_ROOT = "/usr/local/xhprof"; | |
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php"; | |
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php"; | |
// save raw data for this profiler run using default | |
// implementation of iXHProfRuns. | |
$xhprof_runs = new XHProfRuns_Default(); | |
// save the run under a namespace "xhprof_foo" | |
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); | |
echo "---------------\n". | |
"Assuming you have set up the http based UI for \n". | |
"XHProf at some address, you can view run at \n". | |
"http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo\n". | |
"---------------\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment