public function disable(array $options = []) : ProviderInterface { $this->data = uprofiler_disable(); return $this; }
if (extension_loaded('uprofiler')) { uprofiler_enable(UPROFILER_FLAGS_CPU | UPROFILER_FLAGS_MEMORY); } else { if (extension_loaded('tideways')) { tideways_enable(TIDEWAYS_FLAGS_CPU | TIDEWAYS_FLAGS_MEMORY | TIDEWAYS_FLAGS_NO_SPANS); } else { if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 4) { xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_NO_BUILTINS); } else { xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY); } } } register_shutdown_function(function () { if (extension_loaded('uprofiler')) { $data['profile'] = uprofiler_disable(); } else { if (extension_loaded('tideways')) { $data['profile'] = tideways_disable(); } else { $data['profile'] = xhprof_disable(); } } // ignore_user_abort(true) allows your PHP script to continue executing, even if the user has terminated their request. // Further Reading: http://blog.preinheimer.com/index.php?/archives/248-When-does-a-user-abort.html // flush() asks PHP to send any data remaining in the output buffers. This is normally done when the script completes, but // since we're delaying that a bit by dealing with the xhprof stuff, we'll do it now to avoid making the user wait. ignore_user_abort(true); flush(); if (!defined('XHGUI_ROOT_DIR')) { require dirname(dirname(__FILE__)) . '/src/bootstrap.php';
/** * {@inheritdoc} */ public function disable() { return uprofiler_disable(); }
try { $dotenv = new Dotenv\Dotenv(realpath(__DIR__ . '/..')); $dotenv->load(); } catch (InvalidArgumentException $exception) { } // Bootstrap require_once 'Doozr/Bootstrap.php'; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Relay\Runner; // Build queue for running middleware through relay $queue[] = function (Request $request, Response $response, callable $next) { // Boot the App kernel $app = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_APP_NAMESPACE, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT); // Invoke Middleware return $app($request, $response, $next); }; // Create a Relay Runner instance ... $runner = new Runner($queue); // ... and run it with the queue defined above $response = $runner(new Doozr_Request_Web(new Doozr_Request_State()), new Doozr_Response_Web(new Doozr_Response_State())); // Stop profiler & save data $profilerData = uprofiler_disable(); $profiler = new uprofilerRuns_Default(); $profiler->save_run($profilerData, DOOZR_NAMESPACE_FLAT); // After running the whole queue send the response (HTTP way) $responseSender = new Doozr_Response_Sender_Web($response); $responseSender->send(); /* * If you want to call normal files within this directory feel free to :) */
//echo $result['Item']['error']['S'] . "\n"; ////> Executive overflow //echo $result['Item']['message']['S'] . "\n"; // //$uprofiler_ROOT = getcwd(). "/uprofiler"; //include_once $uprofiler_ROOT . "/uprofiler_lib/utils/uprofiler_lib.php"; //include_once $uprofiler_ROOT . "/uprofiler_lib/utils/uprofiler_runs.php"; function bar($x) { if ($x > 0) { bar($x - 1); } } function foo() { for ($idx = 0; $idx < 2; $idx++) { bar($idx); $x = strlen("abc"); } } // start profiling //uprofiler_enable(); include dirname(__FILE__) . "/UprofilerGetSaveRuns.php"; // run program foo(); // stop profiler $uprofiler_data = uprofiler_disable(); $uprofiler_runs = new UprofilerGetSaveRuns(); //$uprofiler_runs->deleteTable(); $run_id = $uprofiler_runs->save_run($uprofiler_data, "brand_name"); echo "---------------\n" . "Assuming you have set up the http based UI for \n" . "uprofiler at some address, you can view run at \n" . "http://<uprofiler-ui-address>/index.php?run={$run_id}&source=brand_name\n" . "---------------\n";