+++ /dev/null
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-// profiling report, added to development
-if (extension_loaded('xhprof') && function_exists('xhprof_enable') && (!empty($CFG->profilingenabled) || !empty($CFG->earlyprofilingenabled))) {
- $ADMIN->add('development', new admin_externalpage('reportprofiling', get_string('pluginname', 'report_profiling'), "$CFG->wwwroot/$CFG->admin/report/profiling/index.php", 'moodle/site:config'));
-}
+++ /dev/null
-/* report_profiling styles */
-
-.path-admin-report-profiling .profilingruntable .label {
- font-weight: bold;
-}
-.path-admin-report-profiling .profiling_worse {
- color: red;
-}
-.path-admin-report-profiling .profiling_better {
- color: green;
-}
-.path-admin-report-profiling .profiling_same {
- color: dimgrey;
-}
-.path-admin-report-profiling .profiling_important,
-.path-admin-report-profiling .flexible .referencerun {
- font-weight: bold;
-}
-.path-admin-report-profiling .flexible .r1 .cell {
- background-color: whitesmoke;
-}
-.path-admin-report-profiling .flexible {
- margin-left:auto;
- margin-right:auto
-}
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package core
+ * Profiling tool.
+ *
+ * @package tool
* @subpackage profiling
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
// TODO: Move all the DB stuff to profiling_db_xxxx() function in xhprof_moodle.php
-require_once(dirname(__FILE__).'/../../../config.php');
+// TODO: it is wrong when core lib references ANY plugin lang strings, maybe more login could be moved here (skodak)
+
+require_once(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
$dbfields = 'runid, url, totalexecutiontime, totalcputime, ' .
'totalcalls, totalmemory, runreference, runcomment, timecreated';
-admin_externalpage_setup('reportprofiling');
+admin_externalpage_setup('toolprofiling');
// Always add listurl if available
if ($listurl) {
- $listurlnav = new moodle_url('/admin/report/profiling/index.php', array('listurl' => $listurl));
+ $listurlnav = new moodle_url('/admin/tool/profiling/index.php', array('listurl' => $listurl));
$PAGE->navbar->add($listurl, $listurlnav);
}
// No run found for script, warn and exit
if (!$run) {
- notice(get_string('cannotfindanyrunforurl', 'report_profiling', $script), 'index.php');
+ notice(get_string('cannotfindanyrunforurl', 'tool_profiling', $script), 'index.php');
}
// Check if there is any previous run marked as reference one
'timecreated DESC', 'runid', 0, 1);
$prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
- $header = get_string('lastrunof', 'report_profiling', $script);
+ $header = get_string('lastrunof', 'tool_profiling', $script);
echo $OUTPUT->heading($header);
$table = profiling_print_run($run, $prevrunid);
echo $table;
$run2 = $runtemp;
}
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
- $header = get_string('differencesbetween2runsof', 'report_profiling', $run1->url);
+ $header = get_string('differencesbetween2runsof', 'tool_profiling', $run1->url);
echo $OUTPUT->heading($header);
$table = profiling_print_rundiff($run1, $run2);
echo $table;
// No run found for runid, warn and exit
if (!$run) {
- notice(get_string('cannotfindanyrunforrunid', 'report_profiling', $runid), 'index.php');
+ notice(get_string('cannotfindanyrunforrunid', 'tool_profiling', $runid), 'index.php');
}
// Check if there is any previous run marked as reference one
'timecreated DESC', 'runid', 0, 1);
$prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
- $header = get_string('summaryof', 'report_profiling', $run->url);
+ $header = get_string('summaryof', 'tool_profiling', $run->url);
echo $OUTPUT->heading($header);
$table = profiling_print_run($run, $prevrunid);
echo $table;
// The flexitable that will root listings
$table = new xhprof_table_sql('profiling-list-table');
- $baseurl = $CFG->wwwroot . '/admin/report/profiling/index.php';
+ $baseurl = $CFG->wwwroot . '/admin/tool/profiling/index.php';
// Check if we are listing all or some URL ones
$sqlconditions = '';
$sqlparams = array();
if (!isset($listurl)) {
- $header = get_string('pluginname', 'report_profiling');
+ $header = get_string('pluginname', 'tool_profiling');
$sqlconditions = '1 = 1';
$table->set_listurlmode(false);
} else {
- $header = get_string('profilingrunsfor', 'report_profiling', $listurl);
+ $header = get_string('profilingrunsfor', 'tool_profiling', $listurl);
$sqlconditions = 'url = :url';
$sqlparams['url'] = $listurl;
$table->set_listurlmode(true);
'url', 'timecreated', 'totalexecutiontime', 'totalcputime',
'totalcalls', 'totalmemory', 'runcomment');
$headers = array(
- get_string('url'), get_string('date'), get_string('executiontime', 'report_profiling'),
- get_string('cputime', 'report_profiling'), get_string('calls', 'report_profiling'),
- get_string('memory', 'report_profiling'), get_string('comment', 'report_profiling'));
+ get_string('url'), get_string('date'), get_string('executiontime', 'tool_profiling'),
+ get_string('cputime', 'tool_profiling'), get_string('calls', 'tool_profiling'),
+ get_string('memory', 'tool_profiling'), get_string('comment', 'tool_profiling'));
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'timecreated', SORT_DESC);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Strings for component 'report_profiling', language 'en', branch 'MOODLE_20_STABLE'
+ * Strings for component 'tool_profiling', language 'en', branch 'MOODLE_22_STABLE'
*
- * @package report_profiling
- * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool
+ * @subpackage profiling
+ * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['calls'] = 'Function calls';
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Profiling tool settings.
+ *
+ * @package tool
+ * @subpackage profiling
+ * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+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'));
+}
--- /dev/null
+/* tool_profiling styles */
+
+.path-admin-tool-profiling .profilingruntable .label {
+ font-weight: bold;
+}
+.path-admin-tool-profiling .profiling_worse {
+ color: red;
+}
+.path-admin-tool-profiling .profiling_better {
+ color: green;
+}
+.path-admin-tool-profiling .profiling_same {
+ color: dimgrey;
+}
+.path-admin-tool-profiling .profiling_important,
+.path-admin-tool-profiling .flexible .referencerun {
+ font-weight: bold;
+}
+.path-admin-tool-profiling .flexible .r1 .cell {
+ background-color: whitesmoke;
+}
+.path-admin-tool-profiling .flexible {
+ margin-left:auto;
+ margin-right:auto
+}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Version details.
+ *
+ * @package tool
+ * @subpackage profiling
+ * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version = 2011091700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011091600; // Requires this Moodle version
+$plugin->component = 'tool_profiling'; // Full name of the plugin (used for diagnostics)
'report' => array(
'backups', 'configlog', 'courseoverview',
- 'customlang', 'log', 'profiling', 'questioninstances',
+ 'customlang', 'log', 'questioninstances',
'security', 'spamcleaner', 'stats', 'unittest'
),
),
'tool' => array(
- 'capability', 'unsuproles'
+ 'capability', 'profiling', 'unsuproles'
),
'webservice' => array(
$table->attributes['class'] = 'profilingruntable';
$table->colclasses = array('label', 'value');
$table->data = array(
- array(get_string('runid', 'report_profiling'), $run->runid),
+ array(get_string('runid', 'tool_profiling'), $run->runid),
array(get_string('url'), $run->url),
array(get_string('date'), userdate($run->timecreated, '%d %B %Y, %H:%M')),
- array(get_string('executiontime', 'report_profiling'), format_float($run->totalexecutiontime / 1000, 3) . ' ms'),
- array(get_string('cputime', 'report_profiling'), format_float($run->totalcputime / 1000, 3) . ' ms'),
- array(get_string('calls', 'report_profiling'), $run->totalcalls),
- array(get_string('memory', 'report_profiling'), format_float($run->totalmemory / 1024, 0) . ' KB'),
- array(get_string('markreferencerun', 'report_profiling'), $referenceform));
+ array(get_string('executiontime', 'tool_profiling'), format_float($run->totalexecutiontime / 1000, 3) . ' ms'),
+ array(get_string('cputime', 'tool_profiling'), format_float($run->totalcputime / 1000, 3) . ' ms'),
+ array(get_string('calls', 'tool_profiling'), $run->totalcalls),
+ array(get_string('memory', 'tool_profiling'), format_float($run->totalmemory / 1024, 0) . ' KB'),
+ array(get_string('markreferencerun', 'tool_profiling'), $referenceform));
$output = $OUTPUT->box(html_writer::table($table), 'generalbox boxwidthwide boxaligncenter profilingrunbox', 'profiling_summary', true);
// Add link to details
- $strviewdetails = get_string('viewdetails', 'report_profiling');
+ $strviewdetails = get_string('viewdetails', 'tool_profiling');
$url = profiling_urls('run', $run->runid);
$output.=$OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');' .
'return false;"' . ' title="">' . $strviewdetails . '</a>', 3, 'main profilinglink');
// If there is one previous run marked as reference, add link to diff
if ($prevrunid) {
- $strviewdiff = get_string('viewdiff', 'report_profiling');
+ $strviewdiff = get_string('viewdiff', 'tool_profiling');
$url = 'index.php?runid=' . $run->runid . '&runid2=' . $prevrunid . '&listurl=' . urlencode($run->url);
$output.=$OUTPUT->heading('<a href="' . $url . '" title="">' . $strviewdiff . '</a>', 3, 'main profilinglink');
}
$table->attributes['class'] = 'profilingruntable';
$table->colclasses = array('label', 'value1', 'value2');
$table->data = array(
- array(get_string('runid', 'report_profiling'),
+ array(get_string('runid', 'tool_profiling'),
'<a href="index.php?runid=' . $run1->runid . '&listurl=' . urlencode($run1->url) . '" title="">' . $run1->runid . '</a>',
'<a href="index.php?runid=' . $run2->runid . '&listurl=' . urlencode($run2->url) . '" title="">' . $run2->runid . '</a>'),
array(get_string('url'), $run1->url, $run2->url),
array(get_string('date'), userdate($run1->timecreated, '%d %B %Y, %H:%M'),
userdate($run2->timecreated, '%d %B %Y, %H:%M')),
- array(get_string('executiontime', 'report_profiling'),
+ array(get_string('executiontime', 'tool_profiling'),
format_float($run1->totalexecutiontime / 1000, 3) . ' ms',
format_float($run2->totalexecutiontime / 1000, 3) . ' ms ' . $diffexecutiontime),
- array(get_string('cputime', 'report_profiling'),
+ array(get_string('cputime', 'tool_profiling'),
format_float($run1->totalcputime / 1000, 3) . ' ms',
format_float($run2->totalcputime / 1000, 3) . ' ms ' . $diffcputime),
- array(get_string('calls', 'report_profiling'), $run1->totalcalls, $run2->totalcalls . ' ' . $diffcalls),
- array(get_string('memory', 'report_profiling'),
+ array(get_string('calls', 'tool_profiling'), $run1->totalcalls, $run2->totalcalls . ' ' . $diffcalls),
+ array(get_string('memory', 'tool_profiling'),
format_float($run1->totalmemory / 1024, 0) . ' KB',
format_float($run2->totalmemory / 1024, 0) . ' KB ' . $diffmemory),
- array(get_string('referencerun', 'report_profiling'), $referencetext1, $referencetext2));
+ array(get_string('referencerun', 'tool_profiling'), $referencetext1, $referencetext2));
$output = $OUTPUT->box(html_writer::table($table), 'generalbox boxwidthwide boxaligncenter profilingrunbox', 'profiling_summary', true);
// Add link to details
- $strviewdetails = get_string('viewdiffdetails', 'report_profiling');
+ $strviewdetails = get_string('viewdiffdetails', 'tool_profiling');
$url = profiling_urls('diff', $run1->runid, $run2->runid);
- //$url = $CFG->wwwroot . '/admin/report/profiling/index.php?run=' . $run->runid;
+ //$url = $CFG->wwwroot . '/admin/tool/profiling/index.php?run=' . $run->runid;
$output.=$OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');' .
'return false;"' . ' title="">' . $strviewdetails . '</a>', 3, 'main profilinglink');
return $output;
global $OUTPUT;
// Build the link to latest run for the script
- $scripturl = new moodle_url('/admin/report/profiling/index.php', array('script' => $row->url, 'listurl' => $row->url));
+ $scripturl = new moodle_url('/admin/tool/profiling/index.php', array('script' => $row->url, 'listurl' => $row->url));
$scriptaction = $OUTPUT->action_link($scripturl, $row->url);
// Decide, based on $this->listurlmode which actions to show
$detailsaction = '';
} else {
// Build link icon to script details (pix + url + actionlink)
- $detailsimg = $OUTPUT->pix_icon('t/right', get_string('profilingfocusscript', 'report_profiling', $row->url));
- $detailsurl = new moodle_url('/admin/report/profiling/index.php', array('listurl' => $row->url));
+ $detailsimg = $OUTPUT->pix_icon('t/right', get_string('profilingfocusscript', 'tool_profiling', $row->url));
+ $detailsurl = new moodle_url('/admin/tool/profiling/index.php', array('listurl' => $row->url));
$detailsaction = $OUTPUT->action_link($detailsurl, $detailsimg);
}
protected function col_timecreated($row) {
global $OUTPUT;
$fdate = userdate($row->timecreated, '%d %b %Y, %H:%M');
- $url = new moodle_url('/admin/report/profiling/index.php', array('runid' => $row->runid, 'listurl' => $row->url));
+ $url = new moodle_url('/admin/tool/profiling/index.php', array('runid' => $row->runid, 'listurl' => $row->url));
return $OUTPUT->action_link($url, $fdate);
}