|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // Copyright (c) 2009 Facebook 00003 // 00004 // Licensed under the Apache License, Version 2.0 (the "License"); 00005 // you may not use this file except in compliance with the License. 00006 // You may obtain a copy of the License at 00007 // 00008 // http://www.apache.org/licenses/LICENSE-2.0 00009 // 00010 // Unless required by applicable law or agreed to in writing, software 00011 // distributed under the License is distributed on an "AS IS" BASIS, 00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 // See the License for the specific language governing permissions and 00014 // limitations under the License. 00015 // 00016 00017 // 00018 // XHProf: A Hierarchical Profiler for PHP 00019 // 00020 // XHProf has two components: 00021 // 00022 // * This module is the UI/reporting component, used 00023 // for viewing results of XHProf runs from a browser. 00024 // 00025 // * Data collection component: This is implemented 00026 // as a PHP extension (XHProf). 00027 // 00028 // 00029 // 00030 // @author(s) Kannan Muthukkaruppan 00031 // Changhao Jiang 00032 // 00033 00034 // start moodle modification: moodleize this script 00035 require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php'); 00036 require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); 00037 require_login(); 00038 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 00039 // end moodle modification 00040 00041 // by default assume that xhprof_html & xhprof_lib directories 00042 // are at the same level. 00043 $GLOBALS['XHPROF_LIB_ROOT'] = dirname(__FILE__) . '/../xhprof_lib'; 00044 00045 require_once $GLOBALS['XHPROF_LIB_ROOT'].'/display/xhprof.php'; 00046 00047 // param name, its type, and default value 00048 $params = array('run' => array(XHPROF_STRING_PARAM, ''), 00049 'wts' => array(XHPROF_STRING_PARAM, ''), 00050 'symbol' => array(XHPROF_STRING_PARAM, ''), 00051 'sort' => array(XHPROF_STRING_PARAM, 'wt'), // wall time 00052 'run1' => array(XHPROF_STRING_PARAM, ''), 00053 'run2' => array(XHPROF_STRING_PARAM, ''), 00054 'source' => array(XHPROF_STRING_PARAM, 'xhprof'), 00055 'all' => array(XHPROF_UINT_PARAM, 0), 00056 ); 00057 00058 // pull values of these params, and create named globals for each param 00059 xhprof_param_init($params); 00060 00061 /* reset params to be a array of variable names to values 00062 by the end of this page, param should only contain values that need 00063 to be preserved for the next page. unset all unwanted keys in $params. 00064 */ 00065 foreach ($params as $k => $v) { 00066 $params[$k] = $$k; 00067 00068 // unset key from params that are using default values. So URLs aren't 00069 // ridiculously long. 00070 if ($params[$k] == $v[1]) { 00071 unset($params[$k]); 00072 } 00073 } 00074 00075 echo "<html>"; 00076 00077 echo "<head><title>XHProf: Hierarchical Profiler Report</title>"; 00078 xhprof_include_js_css(); 00079 echo "</head>"; 00080 00081 echo "<body>"; 00082 00083 $vbar = ' class="vbar"'; 00084 $vwbar = ' class="vwbar"'; 00085 $vwlbar = ' class="vwlbar"'; 00086 $vbbar = ' class="vbbar"'; 00087 $vrbar = ' class="vrbar"'; 00088 $vgbar = ' class="vgbar"'; 00089 00090 // start moodle modification: use own XHProfRuns implementation 00091 //$xhprof_runs_impl = new XHProfRuns_Default() 00092 $xhprof_runs_impl = new moodle_xhprofrun(); 00093 // end moodle modification 00094 00095 displayXHProfReport($xhprof_runs_impl, $params, $source, $run, $wts, 00096 $symbol, $sort, $run1, $run2); 00097 00098 00099 echo "</body>"; 00100 echo "</html>";