mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-79285 xhprof: Add support for optional "reducedata" parameter
This new parameter / property will decide if we want to reduce the run data before processing it: - By default it will be disabled in table mode. - By default it will be enabled in graph mode. - The defaults can be changed by adding reducedata=[0|1] in the URLs - Once data reduction is enabled, it stays enabled while navigating within the xhprof reports.
This commit is contained in:
parent
c841064432
commit
68a2dd57ef
@ -90,6 +90,7 @@ if (!array_key_exists($type, $xhprof_legal_image_types)) {
|
||||
// Start moodle modification: use own XHProfRuns implementation.
|
||||
// $xhprof_runs_impl = new XHProfRuns_Default();
|
||||
$xhprof_runs_impl = new moodle_xhprofrun();
|
||||
$xhprof_runs_impl->set_reducedata(xhprof_get_bool_param('reducedata', 1)); // Reduce data by default.
|
||||
// End moodle modification.
|
||||
|
||||
if (!empty($run)) {
|
||||
|
@ -92,6 +92,12 @@ $vgbar = ' class="vgbar"';
|
||||
// Start moodle modification: use own XHProfRuns implementation.
|
||||
// $xhprof_runs_impl = new XHProfRuns_Default();
|
||||
$xhprof_runs_impl = new moodle_xhprofrun();
|
||||
$reducedata = xhprof_get_bool_param('reducedata', 0); // Don't reduce data by default.
|
||||
$xhprof_runs_impl->set_reducedata($reducedata);
|
||||
if ($reducedata) {
|
||||
// We need to inject it, so we continue in "reduced data mode" all the time.
|
||||
$params['reducedata'] = $reducedata;
|
||||
}
|
||||
// End moodle modification.
|
||||
|
||||
displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts,
|
||||
|
@ -859,6 +859,9 @@ class moodle_xhprofrun implements iXHProfRuns {
|
||||
protected $totalmemory = 0;
|
||||
protected $timecreated = 0;
|
||||
|
||||
/** @var bool Decide if we want to reduce profiling data or no */
|
||||
protected bool $reducedata = false;
|
||||
|
||||
public function __construct() {
|
||||
$this->timecreated = time();
|
||||
}
|
||||
@ -889,6 +892,10 @@ class moodle_xhprofrun implements iXHProfRuns {
|
||||
return unserialize(base64_decode($rec->data));
|
||||
} else {
|
||||
$info = unserialize(gzuncompress(base64_decode($rec->data)));
|
||||
if (!$this->reducedata) {
|
||||
// We want to return the full data.
|
||||
return $info;
|
||||
}
|
||||
|
||||
// We want to apply some transformations here, in order to reduce
|
||||
// the information for some complex (too many levels) cases.
|
||||
@ -967,6 +974,15 @@ class moodle_xhprofrun implements iXHProfRuns {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable reducing profiling data.
|
||||
*
|
||||
* @param bool $reducedata Decide if we want to reduce profiling data (true) or no (false).
|
||||
*/
|
||||
public function set_reducedata(bool $reducedata): void {
|
||||
$this->reducedata = $reducedata;
|
||||
}
|
||||
|
||||
// Private API starts here.
|
||||
|
||||
protected function sum_calls($sum, $data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user