MDL-55292 performance: Allow Tideways profiler extension.
PHP7 doesn't have any default XHProf support and all other investigated forks don't have stable PHP7. Tideways is under active development and is easy to install. The data format is compatible with XHProf so it is a drop-in replacement in that way.
This commit is contained in:
@@ -32,7 +32,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
||||
$xhprofenabled = extension_loaded('xhprof') && function_exists('xhprof_enable');
|
||||
$xhprofenabled = extension_loaded('xhprof') || extension_loaded('tideways');
|
||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
|
||||
// Main profiling switch.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
// profiling tool, added to development
|
||||
if (extension_loaded('xhprof') && function_exists('xhprof_enable') && (!empty($CFG->profilingenabled) || !empty($CFG->earlyprofilingenabled))) {
|
||||
$ADMIN->add('development', new admin_externalpage('toolprofiling', get_string('pluginname', 'tool_profiling'), "$CFG->wwwroot/$CFG->admin/tool/profiling/index.php", 'moodle/site:config'));
|
||||
if ((extension_loaded('xhprof') || extension_loaded('tideways')) && (!empty($CFG->profilingenabled) || !empty($CFG->earlyprofilingenabled))) {
|
||||
$ADMIN->add('development', new admin_externalpage('toolprofiling', get_string('pluginname', 'tool_profiling'),
|
||||
"$CFG->wwwroot/$CFG->admin/tool/profiling/index.php", 'moodle/site:config'));
|
||||
}
|
||||
|
||||
@@ -36,3 +36,4 @@ TODO:
|
||||
20101122 - MDL-24600 - Eloy Lafuente (stronk7): Original import of 0.9.2 release
|
||||
20110318 - MDL-26891 - Eloy Lafuente (stronk7): Implemented earlier profiling runs
|
||||
20130621 - MDL-39733 - Eloy Lafuente (stronk7): Export & import of profiling runs
|
||||
20160721 - MDL-55292 - Russell Smith (mr-russ): Add support for tideways profiler collection for PHP7
|
||||
|
||||
@@ -69,7 +69,7 @@ function profiling_start() {
|
||||
global $CFG, $SESSION, $SCRIPT;
|
||||
|
||||
// If profiling isn't available, nothing to start
|
||||
if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
|
||||
if (!extension_loaded('xhprof') && !extension_loaded('tideways')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,11 @@ function profiling_start() {
|
||||
|
||||
// Arrived here, the script is going to be profiled, let's do it
|
||||
$ignore = array('call_user_func', 'call_user_func_array');
|
||||
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
||||
if (extension_loaded('tideways')) {
|
||||
tideways_enable(TIDEWAYS_FLAGS_CPU + TIDEWAYS_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
||||
} else {
|
||||
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
||||
}
|
||||
profiling_is_running(true);
|
||||
|
||||
// Started, return true
|
||||
@@ -160,7 +164,7 @@ function profiling_stop() {
|
||||
global $CFG, $DB, $SCRIPT;
|
||||
|
||||
// If profiling isn't available, nothing to stop
|
||||
if (!extension_loaded('xhprof') || !function_exists('xhprof_enable')) {
|
||||
if (!extension_loaded('xhprof') && !extension_loaded('tideways')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,7 +183,11 @@ function profiling_stop() {
|
||||
|
||||
// Arrived here, profiling is running, stop and save everything
|
||||
profiling_is_running(false);
|
||||
$data = xhprof_disable();
|
||||
if (extension_loaded('tideways')) {
|
||||
$data = tideways_disable();
|
||||
} else {
|
||||
$data = xhprof_disable();
|
||||
}
|
||||
|
||||
// We only save the run after ensuring the DB table exists
|
||||
// (this prevents problems with profiling runs enabled in
|
||||
|
||||
Reference in New Issue
Block a user