Skip to content

Commit

Permalink
MDL-38161 Upgrade xhprof to 02-2013 commits
Browse files Browse the repository at this point in the history
Note this continues being version 0.9.2 and
only a few changes have landed since 3y ago.
(the important stuff is in the xhprof extension,
not in this UI package using it)
  • Loading branch information
stronk7 committed Feb 22, 2013
1 parent 1dd6835 commit 6919693
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 29 deletions.
8 changes: 5 additions & 3 deletions lib/xhprof/readme_moodle.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,19 @@
Description of XHProf 0.9.2 library/viewer import into Moodle Description of XHProf 0.9.2 library/viewer import into Moodle


Removed: Removed (commit #1):
* .arcconfig - Definitions for arcanist/phabricator removed completely
* composer.json - Composer's definition removed completely
* examples - examples dir removed completely * examples - examples dir removed completely
* extension - extension dir removed completely * extension - extension dir removed completely
* package.xml - PECL package definition removed completely * package.xml - PECL package definition removed completely
* xhprof_html/docs - documentation dir removed completely * xhprof_html/docs - documentation dir removed completely


Added: Added (commit #2 - always taken from current moodle.git master):
* index.html - prevent directory browsing on misconfigured servers * index.html - prevent directory browsing on misconfigured servers
* xhprof_moodle.php - containing all the stuff needed to run the xhprof profiler within Moodle * xhprof_moodle.php - containing all the stuff needed to run the xhprof profiler within Moodle
* readme_moodle.txt - this file ;-) * readme_moodle.txt - this file ;-)


Our changes: Look for "moodle" in code Our changes: Look for "moodle" in code (commit #3 - always mimic from current moodle.git master):
* xhprof_html/index.php ----| * xhprof_html/index.php ----|
* xhprof_html/callgraph.php -|=> Changed to use own DB iXHProfRuns implementation (moodle_xhprofrun) * xhprof_html/callgraph.php -|=> Changed to use own DB iXHProfRuns implementation (moodle_xhprofrun)
* xhprof_html/typeahead.php -| * xhprof_html/typeahead.php -|
Expand Down
11 changes: 5 additions & 6 deletions lib/xhprof/xhprof_html/callgraph.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
* @author Changhao Jiang (cjiang@facebook.com) * @author Changhao Jiang (cjiang@facebook.com)
*/ */


// start moodle modification: moodleize this script // Start moodle modification: moodleize this script.
require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
require_login(); require_login();
require_capability('moodle/site:config', context_system::instance()); require_capability('moodle/site:config', context_system::instance());
// end moodle modification // End moodle modification.


// by default assume that xhprof_html & xhprof_lib directories // by default assume that xhprof_html & xhprof_lib directories
// are at the same level. // are at the same level.
Expand Down Expand Up @@ -85,11 +85,10 @@
$type = $params['type'][1]; // default image type. $type = $params['type'][1]; // default image type.
} }


// start moodle modification: use own XHProfRuns implementation // Start moodle modification: use own XHProfRuns implementation.
//$xhprof_runs_impl = new XHProfRuns_Default(); // $xhprof_runs_impl = new XHProfRuns_Default();
require_once($GLOBALS['XHPROF_LIB_ROOT'].'/../xhprof_moodle.php');
$xhprof_runs_impl = new moodle_xhprofrun(); $xhprof_runs_impl = new moodle_xhprofrun();
// end moodle modification // End moodle modification.


if (!empty($run)) { if (!empty($run)) {
// single run call graph image generation // single run call graph image generation
Expand Down
8 changes: 3 additions & 5 deletions lib/xhprof/xhprof_html/css/xhprof.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */


/* start moodle modification: add basic, smaller, font specs */ /* Start moodle modification: add basic, smaller, font specs */
body, p, table, li { body, p, table, li {
font: normal normal normal 13px/1.231 arial, helvetica, clean, sans-serif; font: normal normal normal 13px/1.231 arial, helvetica, clean, sans-serif;
} }

/* End moodle modification */
/* end moodle modification */



td.sorted { td.sorted {
color:#0000FF; color:#0000FF;
Expand Down
10 changes: 5 additions & 5 deletions lib/xhprof/xhprof_html/index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
// Changhao Jiang // Changhao Jiang
// //


// start moodle modification: moodleize this script // Start moodle modification: moodleize this script.
require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
require_login(); require_login();
require_capability('moodle/site:config', context_system::instance()); require_capability('moodle/site:config', context_system::instance());
// end moodle modification // End moodle modification.


// by default assume that xhprof_html & xhprof_lib directories // by default assume that xhprof_html & xhprof_lib directories
// are at the same level. // are at the same level.
Expand Down Expand Up @@ -87,10 +87,10 @@
$vrbar = ' class="vrbar"'; $vrbar = ' class="vrbar"';
$vgbar = ' class="vgbar"'; $vgbar = ' class="vgbar"';


// start moodle modification: use own XHProfRuns implementation // Start moodle modification: use own XHProfRuns implementation.
//$xhprof_runs_impl = new XHProfRuns_Default() // $xhprof_runs_impl = new XHProfRuns_Default();
$xhprof_runs_impl = new moodle_xhprofrun(); $xhprof_runs_impl = new moodle_xhprofrun();
// end moodle modification // End moodle modification.


displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts, displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts,
$symbol, $sort, $run1, $run2); $symbol, $sort, $run1, $run2);
Expand Down
Binary file modified lib/xhprof/xhprof_html/jquery/indicator.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions lib/xhprof/xhprof_html/typeahead.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@
* Changhao Jiang * Changhao Jiang
*/ */


// start moodle modification: moodleize this script // Start moodle modification: moodleize this script.
require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
require_login(); require_login();
require_capability('moodle/site:config', context_system::instance()); require_capability('moodle/site:config', context_system::instance());
// end moodle modification // End moodle modification.


// by default assume that xhprof_html & xhprof_lib directories // by default assume that xhprof_html & xhprof_lib directories
// are at the same level. // are at the same level.
$GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib'; $GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib';


require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php'; require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php';


// start moodle modification: use own XHProfRuns implementation // Start moodle modification: use own XHProfRuns implementation.
//$xhprof_runs_impl = new XHProfRuns_Default(); // $xhprof_runs_impl = new XHProfRuns_Default();
require_once($GLOBALS['XHPROF_LIB_ROOT'].'/../xhprof_moodle.php');
$xhprof_runs_impl = new moodle_xhprofrun(); $xhprof_runs_impl = new moodle_xhprofrun();
// end moodle modification // End moodle modification.


require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/typeahead_common.php'; require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/typeahead_common.php';
10 changes: 7 additions & 3 deletions lib/xhprof/xhprof_lib/utils/callgraph_utils.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"jpg" => 1, "jpg" => 1,
"gif" => 1, "gif" => 1,
"png" => 1, "png" => 1,
"svg" => 1, // support scalable vector graphic
"ps" => 1, "ps" => 1,
); );


Expand Down Expand Up @@ -68,6 +69,9 @@ function xhprof_generate_mime_header($type, $length) {
case 'png': case 'png':
$mime = 'image/png'; $mime = 'image/png';
break; break;
case 'svg':
$mime = 'image/svg+xml'; // content type for scalable vector graphic
break;
case 'ps': case 'ps':
$mime = 'application/postscript'; $mime = 'application/postscript';
default: default:
Expand Down Expand Up @@ -103,11 +107,11 @@ function xhprof_generate_image_by_dot($dot_script, $type) {
2 => array("pipe", "w") 2 => array("pipe", "w")
); );


// start moodle modification: use $CFG->pathtodot for executing this // Start moodle modification: use $CFG->pathtodot for executing this.
//$cmd = " dot -T".$type; // $cmd = " dot -T".$type;
global $CFG; global $CFG;
$cmd = (!empty($CFG->pathtodot) ? $CFG->pathtodot : 'dot') . ' -T' . $type; $cmd = (!empty($CFG->pathtodot) ? $CFG->pathtodot : 'dot') . ' -T' . $type;
// end moodle modification // End moodle modification.


$process = proc_open($cmd, $descriptorspec, $pipes, "/tmp", array()); $process = proc_open($cmd, $descriptorspec, $pipes, "/tmp", array());
if (is_resource($process)) { if (is_resource($process)) {
Expand Down
4 changes: 3 additions & 1 deletion lib/xhprof/xhprof_lib/utils/xhprof_runs.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public function save_run($xhprof_data, $type, $run_id = null) {
function list_runs() { function list_runs() {
if (is_dir($this->dir)) { if (is_dir($this->dir)) {
echo "<hr/>Existing runs:\n<ul>\n"; echo "<hr/>Existing runs:\n<ul>\n";
foreach (glob("{$this->dir}/*.{$this->suffix}") as $file) { $files = glob("{$this->dir}/*.{$this->suffix}");
usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
foreach ($files as $file) {
list($run,$source) = explode('.', basename($file)); list($run,$source) = explode('.', basename($file));
echo '<li><a href="' . htmlentities($_SERVER['SCRIPT_NAME']) echo '<li><a href="' . htmlentities($_SERVER['SCRIPT_NAME'])
. '?run=' . htmlentities($run) . '&source=' . '?run=' . htmlentities($run) . '&source='
Expand Down

0 comments on commit 6919693

Please sign in to comment.