Created
January 27, 2011 19:28
-
-
Save smalyshev/799049 to your computer and use it in GitHub Desktop.
xhprof with Sugar
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
<?php | |
if(mt_rand(0, 200) != 42) { | |
return; | |
} | |
if(!empty($_REQUEST['entryPoint']) && ($_REQUEST['entryPoint'] == 'getImage' || $_REQUEST['entryPoint'] == 'getYUIComboFile')) { | |
return; | |
} | |
xhprof_enable(XHPROF_FLAGS_LONGNAMES); | |
$xhprof_enabled = true; | |
include_once "xhprof_lib/utils/xhprof_lib.php"; | |
include_once "xhprof_lib/utils/xhprof_runs.php"; | |
function xhprof_collect() | |
{ | |
global $xhprof_enabled; | |
if(empty($xhprof_enabled)) return; | |
$xhprof_data = xhprof_disable(); | |
$xhprof_runs = new XHProfRuns_Default(); | |
$name = str_replace(array(".", "-"), array("_", "_"), basename(getcwd())); | |
if(isset($_REQUEST['module'])) { | |
$name .= "_".$_REQUEST['module']; | |
} | |
if(isset($_REQUEST['action'])) { | |
$name .= "_".$_REQUEST['action']; | |
} | |
$run_id = $xhprof_runs->save_run($xhprof_data, $name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment