Skip to content
Snippets Groups Projects
Commit d181bcc9 authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Fix tideways support and make profiling work with command line tools. (#1487)

Also remove obsolete xhprof support.
parent 3f3944f8
No related merge requests found
<?php
// If the XHProf profiler is enabled, set it up now:
$xhprof = getenv('VUFIND_PROFILER_XHPROF');
if (!empty($xhprof)) {
if (extension_loaded('xhprof')) {
xhprof_enable();
} elseif (extension_loaded('tideways')) {
tideways_enable();
} else {
$xhprof = false;
// If the profiler is enabled, set it up now:
$vufindProfiler = getenv('VUFIND_PROFILER_XHPROF');
if (!empty($vufindProfiler)) {
if (extension_loaded('tideways_xhprof')) {
tideways_xhprof_enable();
// Handle final profiling details, if necessary:
register_shutdown_function(function () use ($vufindProfiler) {
$xhprofData = tideways_xhprof_disable();
$xhprofRunId = uniqid();
$suffix = 'vufind';
$dir = ini_get('xhprof.output_dir');
if (empty($dir)) {
$dir = sys_get_temp_dir();
}
file_put_contents(
"$dir/$xhprofRunId.$suffix.xhprof", serialize($xhprofData)
);
$url = "$vufindProfiler?run=$xhprofRunId&source=$suffix";
echo "<a href='$url'>Profiler output</a>";
});
}
}
......@@ -69,17 +81,3 @@ if (!class_exists('Zend\Loader\AutoloaderFactory')) {
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
// Handle final profiling details, if necessary:
if ($xhprof) {
$xhprofData = extension_loaded('xhprof') ? xhprof_disable() : tideways_disable();
$xhprofRunId = uniqid();
$suffix = 'vufind';
$dir = ini_get('xhprof.output_dir');
if (empty($dir)) {
$dir = sys_get_temp_dir();
}
file_put_contents("$dir/$xhprofRunId.$suffix.xhprof", serialize($xhprofData));
$url = "$xhprof?run=$xhprofRunId&source=$suffix";
echo "<a href='$url'>Profiler output</a>";
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment