mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
Merge branch 'MDL-62280-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
commit
bb35eb7da7
3 changed files with 32 additions and 7 deletions
|
@ -30,7 +30,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||||
$ADMIN->add('development', $temp);
|
$ADMIN->add('development', $temp);
|
||||||
|
|
||||||
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
||||||
$xhprofenabled = extension_loaded('xhprof') || extension_loaded('tideways');
|
$xhprofenabled = extension_loaded('tideways_xhprof');
|
||||||
|
$xhprofenabled = $xhprofenabled || extension_loaded('tideways');
|
||||||
|
$xhprofenabled = $xhprofenabled || extension_loaded('xhprof');
|
||||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
|
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
|
||||||
// Main profiling switch.
|
// Main profiling switch.
|
||||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||||
|
|
|
@ -25,8 +25,12 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
// profiling tool, added to development
|
// Profiling tool, added to development.
|
||||||
if ((extension_loaded('xhprof') || extension_loaded('tideways')) && (!empty($CFG->profilingenabled) || !empty($CFG->earlyprofilingenabled))) {
|
$hasextension = extension_loaded('tideways_xhprof');
|
||||||
|
$hasextension = $hasextension || extension_loaded('tideways');
|
||||||
|
$hasextension = $hasextension || extension_loaded('xhprof');
|
||||||
|
$isenabled = !empty($CFG->profilingenabled) || !empty($CFG->earlyprofilingenabled);
|
||||||
|
if ($hasextension && $isenabled) {
|
||||||
$ADMIN->add('development', new admin_externalpage('toolprofiling', get_string('pluginname', 'tool_profiling'),
|
$ADMIN->add('development', new admin_externalpage('toolprofiling', get_string('pluginname', 'tool_profiling'),
|
||||||
"$CFG->wwwroot/$CFG->admin/tool/profiling/index.php", 'moodle/site:config'));
|
"$CFG->wwwroot/$CFG->admin/tool/profiling/index.php", 'moodle/site:config'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,21 @@ function profiling_is_saved($value = null) {
|
||||||
return $saved;
|
return $saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether PHP profiling is available.
|
||||||
|
*
|
||||||
|
* This check ensures that one of the available PHP Profiling extensions is available.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function profiling_available() {
|
||||||
|
$hasextension = extension_loaded('tideways_xhprof');
|
||||||
|
$hasextension = $hasextension || extension_loaded('tideways');
|
||||||
|
$hasextension = $hasextension || extension_loaded('xhprof');
|
||||||
|
|
||||||
|
return $hasextension;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start profiling observing all the configuration
|
* Start profiling observing all the configuration
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +85,7 @@ function profiling_start() {
|
||||||
global $CFG, $SESSION, $SCRIPT;
|
global $CFG, $SESSION, $SCRIPT;
|
||||||
|
|
||||||
// If profiling isn't available, nothing to start
|
// If profiling isn't available, nothing to start
|
||||||
if (!extension_loaded('xhprof') && !extension_loaded('tideways')) {
|
if (!profiling_available()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +162,9 @@ function profiling_start() {
|
||||||
|
|
||||||
// Arrived here, the script is going to be profiled, let's do it
|
// Arrived here, the script is going to be profiled, let's do it
|
||||||
$ignore = array('call_user_func', 'call_user_func_array');
|
$ignore = array('call_user_func', 'call_user_func_array');
|
||||||
if (extension_loaded('tideways')) {
|
if (extension_loaded('tideways_xhprof')) {
|
||||||
|
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_CPU + TIDEWAYS_XHPROF_FLAGS_MEMORY);
|
||||||
|
} else if (extension_loaded('tideways')) {
|
||||||
tideways_enable(TIDEWAYS_FLAGS_CPU + TIDEWAYS_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
tideways_enable(TIDEWAYS_FLAGS_CPU + TIDEWAYS_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
||||||
} else {
|
} else {
|
||||||
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY, array('ignored_functions' => $ignore));
|
||||||
|
@ -165,7 +182,7 @@ function profiling_stop() {
|
||||||
global $CFG, $DB, $SCRIPT;
|
global $CFG, $DB, $SCRIPT;
|
||||||
|
|
||||||
// If profiling isn't available, nothing to stop
|
// If profiling isn't available, nothing to stop
|
||||||
if (!extension_loaded('xhprof') && !extension_loaded('tideways')) {
|
if (!profiling_available()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +201,9 @@ function profiling_stop() {
|
||||||
|
|
||||||
// Arrived here, profiling is running, stop and save everything
|
// Arrived here, profiling is running, stop and save everything
|
||||||
profiling_is_running(false);
|
profiling_is_running(false);
|
||||||
if (extension_loaded('tideways')) {
|
if (extension_loaded('tideways_xhprof')) {
|
||||||
|
$data = tideways_xhprof_disable();
|
||||||
|
} else if (extension_loaded('tideways')) {
|
||||||
$data = tideways_disable();
|
$data = tideways_disable();
|
||||||
} else {
|
} else {
|
||||||
$data = xhprof_disable();
|
$data = xhprof_disable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue