MDL-29029 move profiling to admin tools

AMOS BEGIN
 MOV [calls,report_profiling],[calls,tool_profiling]
 MOV [cannotfindanyrunforurl,report_profiling],[cannotfindanyrunforurl,tool_profiling]
 MOV [cannotfindanyrunforrunid,report_profiling],[cannotfindanyrunforrunid,tool_profiling]
 MOV [comment,report_profiling],[comment,tool_profiling]
 MOV [differencesbetween2runsof,report_profiling],[differencesbetween2runsof,tool_profiling]
 MOV [executiontime,report_profiling],[executiontime,tool_profiling]
 MOV [cputime,report_profiling],[cputime,tool_profiling]
 MOV [lastrunof,report_profiling],[lastrunof,tool_profiling]
 MOV [markreferencerun,report_profiling],[markreferencerun,tool_profiling]
 MOV [memory,report_profiling],[memory,tool_profiling]
 MOV [pluginname,report_profiling],[pluginname,tool_profiling]
 MOV [profilingfocusscript,report_profiling],[profilingfocusscript,tool_profiling]
 MOV [profilingruns,report_profiling],[profilingruns,tool_profiling]
 MOV [profilingrunsfor,report_profiling],[profilingrunsfor,tool_profiling]
 MOV [referencerun,report_profiling],[referencerun,tool_profiling]
 MOV [runid,report_profiling],[runid,tool_profiling]
 MOV [summaryof,report_profiling],[summaryof,tool_profiling]
 MOV [viewdetails,report_profiling],[viewdetails,tool_profiling]
 MOV [viewdiff,report_profiling],[viewdiff,tool_profiling]
 MOV [viewdiffdetails,report_profiling],[viewdiffdetails,tool_profiling]
AMOS END
This commit is contained in:
Petr Skoda 2011-09-17 10:04:29 +02:00
parent a3c0e9bbb0
commit 187536f6c4
9 changed files with 132 additions and 75 deletions

View File

@ -1,8 +0,0 @@
<?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'));
}

View File

@ -1,25 +0,0 @@
/* 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
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,7 +15,9 @@
// 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
@ -24,7 +25,9 @@
// 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');
@ -41,11 +44,11 @@ $runcomment = optional_param('runcomment', null, PARAM_TEXT);
$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);
}
@ -65,7 +68,7 @@ if (isset($script)) {
// 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
@ -75,7 +78,7 @@ if (isset($script)) {
'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;
@ -93,7 +96,7 @@ if (isset($script)) {
$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;
@ -117,7 +120,7 @@ if (isset($script)) {
// 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
@ -127,7 +130,7 @@ if (isset($script)) {
'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;
@ -139,17 +142,17 @@ if (isset($script)) {
// 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);
@ -167,9 +170,9 @@ if (isset($script)) {
'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);

View File

@ -16,11 +16,12 @@
// 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';

View File

@ -0,0 +1,31 @@
<?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'));
}

View File

@ -0,0 +1,25 @@
/* 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
}

View File

@ -0,0 +1,30 @@
<?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)

View File

@ -343,7 +343,7 @@ class plugin_manager {
'report' => array(
'backups', 'configlog', 'courseoverview',
'customlang', 'log', 'profiling', 'questioninstances',
'customlang', 'log', 'questioninstances',
'security', 'spamcleaner', 'stats', 'unittest'
),
@ -367,7 +367,7 @@ class plugin_manager {
),
'tool' => array(
'capability', 'unsuproles'
'capability', 'profiling', 'unsuproles'
),
'webservice' => array(

View File

@ -280,23 +280,23 @@ function profiling_print_run($run, $prevrunid = null) {
$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 . '&amp;runid2=' . $prevrunid . '&amp;listurl=' . urlencode($run->url);
$output.=$OUTPUT->heading('<a href="' . $url . '" title="">' . $strviewdiff . '</a>', 3, 'main profilinglink');
}
@ -327,28 +327,28 @@ function profiling_print_rundiff($run1, $run2) {
$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;
@ -535,7 +535,7 @@ class xhprof_table_sql extends table_sql {
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
@ -543,8 +543,8 @@ class xhprof_table_sql extends table_sql {
$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);
}
@ -557,7 +557,7 @@ class xhprof_table_sql extends table_sql {
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);
}