Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created February 10, 2010 12:29
Show Gist options
  • Save videlalvaro/300261 to your computer and use it in GitHub Desktop.
Save videlalvaro/300261 to your computer and use it in GitHub Desktop.
<?php
$enable_xhprof = apc_fetch('enable_xhprof');
if($enable_xhprof)
{
xhprof_enable(XHPROF_FLAGS_MEMORY, array('ignored_functions' => array('call_user_func',
'call_user_func_array')));
}
define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..'));
define('SF_APP', 'frontend');
define('SF_ENVIRONMENT', 'prod');
define('SF_DEBUG', false);
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
sfContext::getInstance()->getController()->dispatch();
if($enable_xhprof)
{
// stop profiler
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = '/srv/www/vhosts';
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default('/tmp/xhprof');
$module = sfContext::getInstance()->getModuleName();
$module = empty($module) ? 'default' : $module;
$action = sfContext::getInstance()->getActionName();
$action = empty($action) ? 'index' : $action;
$xhprof_runs->save_run($xhprof_data, $module.'.'.$action);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment