
Untitled
By: a guest on
May 5th, 2012 | syntax:
PHP | size: 1.24 KB | hits: 91 | expires: Never
<?php
if (extension_loaded('xhprof')) {
if(isset($_GET['_xhprof_xhr_']) && $_GET['_xhprof_xhr_'] == 1){
if(!session_id()){
session_start();
}
if($_GET['doclear'] == 1){
unset($_SESSION['_xhprof_']);
$_SESSION['_xhprof_'] = array();
echo 'xhprof session buffer cleared..\n';
$dir = '/var/tmp/xhprof';
$fp = opendir($dir);
if ( $fp ) {
while ($f = readdir($fp)) {
$file = $dir . "/" . $f;
if ($f == "." || $f == "..") {
continue;
}
else if (is_dir($file) && !is_link($file)) {
rrmdir($file);
}
else {
unlink($file);
}
}
closedir($fp);
rmdir($dir);
}
echo 'xhprof files cleared..\n';
exit();
}
rsort($_SESSION['_xhprof_']);
echo json_encode($_SESSION['_xhprof_']);
exit();
}
else{
include_once '/usr/share/php/xhprof_lib/utils/xhprof_lib.php';
include_once '/usr/share/php/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
}
?>