* Log sums from profiling into "profiling" table in db.
*
* You have to create a 'profiling' table in your database before using
- * this feature, see maintenance/archives/patch-profiling.sql
+ * this feature. Run set $wgProfileToDatabase to true in
+ * LocalSettings.php and run maintenance/update.php or otherwise
+ * manually add patch-profiling.sql to your database.
*
* To enable profiling, edit StartProfiler.php
*/
array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
+ array( 'doEnableProfiling' ),
);
}
}
}
+ protected function doEnableProfiling() {
+ global $wgProfileToDatabase;
+ if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) {
+ $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
+ }
+ }
+
protected function doMaybeProfilingMemoryUpdate() {
if ( !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
// Simply ignore
array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
+ array( 'doEnableProfiling' ),
);
}
$this->output( "...fulltext search table appears to be in order.\n" );
}
}
+
+ protected function doEnableProfiling() {
+ global $wgProfileToDatabase;
+ if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) {
+ $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
+ }
+ }
}
--- /dev/null
+-- profiling table
+-- This is optional
+
+CREATE TABLE /*_*/profiling (
+ pf_count int NOT NULL default 0,
+ pf_time float NOT NULL default 0,
+ pf_memory float NOT NULL default 0,
+ pf_name varchar(255) NOT NULL default '',
+ pf_server varchar(30) NOT NULL default ''
+);
+
+CREATE UNIQUE INDEX /*i*/pf_name_server ON /*_*/profiling (pf_name, pf_server);
if( !$dbr->tableExists( 'profiling' ) ) {
echo '<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
- . '<p>If you want to log profiling data, create the table using '
- . '<code>maintenance/archives/patch-profiling.sql</code> and enable '
- . '<code>$wgProfileToDatabase</code>.</p>'
+ . '<p>If you want to log profiling data, enable <code>$wgProfileToDatabase</code>'
+ . ' in your LocalSettings.php and run <code>maintenance/update.php</code> to'
+ . ' create the profiling table.'
. '</body></html>';
exit( 1 );
}