Wrap job execution around profiling calls.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Apr 2013 04:50:34 +0000 (21:50 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Apr 2013 19:22:33 +0000 (12:22 -0700)
Change-Id: Idf184b7c2f7003032d3a28830ee9c4a1eaeaa98b

includes/Wiki.php
includes/job/jobs/RefreshLinksJob.php
maintenance/runJobs.php

index f8f699c..b9a7aac 100644 (file)
@@ -621,11 +621,13 @@ class MediaWiki {
                        if ( $job ) {
                                $output = $job->toString() . "\n";
                                $t = - microtime( true );
+                               wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
                                $success = $job->run();
+                               wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
                                $group->ack( $job ); // done
                                $t += microtime( true );
                                $t = round( $t * 1000 );
-                               if ( !$success ) {
+                               if ( $success === false ) {
                                        $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
                                } else {
                                        $output .= "Success, Time: $t ms\n";
index 9dbe827..d096da6 100644 (file)
@@ -37,14 +37,11 @@ class RefreshLinksJob extends Job {
         * @return boolean success
         */
        function run() {
-               wfProfileIn( __METHOD__ );
-
                $linkCache = LinkCache::singleton();
                $linkCache->clear();
 
                if ( is_null( $this->title ) ) {
                        $this->error = "refreshLinks: Invalid title";
-                       wfProfileOut( __METHOD__ );
                        return false;
                }
 
@@ -59,13 +56,11 @@ class RefreshLinksJob extends Job {
                if ( !$revision ) {
                        $this->error = 'refreshLinks: Article not found "' .
                                $this->title->getPrefixedDBkey() . '"';
-                       wfProfileOut( __METHOD__ );
                        return false; // XXX: what if it was just deleted?
                }
 
                self::runForTitleInternal( $this->title, $revision, __METHOD__ );
 
-               wfProfileOut( __METHOD__ );
                return true;
        }
 
@@ -123,14 +118,11 @@ class RefreshLinksJob2 extends Job {
        function run() {
                global $wgUpdateRowsPerJob;
 
-               wfProfileIn( __METHOD__ );
-
                $linkCache = LinkCache::singleton();
                $linkCache->clear();
 
                if ( is_null( $this->title ) ) {
                        $this->error = "refreshLinks2: Invalid title";
-                       wfProfileOut( __METHOD__ );
                        return false;
                }
 
@@ -181,7 +173,6 @@ class RefreshLinksJob2 extends Job {
                        JobQueueGroup::singleton()->push( $jobs );
                }
 
-               wfProfileOut( __METHOD__ );
                return true;
        }
 
index ef80df5..1f48ffe 100644 (file)
@@ -95,6 +95,7 @@ class RunJobs extends Maintenance {
 
                                // Run the job...
                                $t = microtime( true );
+                               wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
                                try {
                                        $status = $job->run();
                                        $error = $job->getLastError();
@@ -102,6 +103,7 @@ class RunJobs extends Maintenance {
                                        $status = false;
                                        $error = get_class( $e ) . ': ' . $e->getMessage();
                                }
+                               wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
                                $timeMs = intval( ( microtime( true ) - $t ) * 1000 );
 
                                // Mark the job as done on success or when the job cannot be retried