Index: trunk/phase3/maintenance/dumpTextPass.php |
— | — | @@ -37,6 +37,11 @@ |
38 | 38 | var $input = "php://stdin"; |
39 | 39 | var $fetchCount = 0; |
40 | 40 | var $prefetchCount = 0; |
| 41 | + var $lastTime = 0; |
| 42 | + var $pageCountLast = 0; |
| 43 | + var $revCountLast = 0; |
| 44 | + var $prefetchCountLast = 0; |
| 45 | + var $fetchCountLast = 0; |
41 | 46 | |
42 | 47 | var $failures = 0; |
43 | 48 | var $maxFailures = 5; |
— | — | @@ -51,6 +56,14 @@ |
52 | 57 | var $spawnRead = false; |
53 | 58 | var $spawnErr = false; |
54 | 59 | |
| 60 | + var $ID = 0; |
| 61 | + |
| 62 | + function initProgress( $history ) { |
| 63 | + parent::initProgress(); |
| 64 | + $this->ID = getmypid(); |
| 65 | + $this->lastTime = $this->startTime; |
| 66 | + } |
| 67 | + |
55 | 68 | function dump( $history, $text = WikiExporter::TEXT ) { |
56 | 69 | # This shouldn't happen if on console... ;) |
57 | 70 | header( 'Content-type: text/html; charset=UTF-8' ); |
— | — | @@ -128,23 +141,52 @@ |
129 | 142 | } |
130 | 143 | |
131 | 144 | if ( $this->reporting ) { |
132 | | - $delta = wfTime() - $this->startTime; |
133 | 145 | $now = wfTimestamp( TS_DB ); |
134 | | - if ( $delta ) { |
135 | | - $rate = $this->pageCount / $delta; |
136 | | - $revrate = $this->revCount / $delta; |
| 146 | + $deltaAll = wfTime() - $this->startTime; |
| 147 | + $deltaPart = wfTime() - $this->lastTime; |
| 148 | + $this->pageCountPart = $this->pageCount - $this->pageCountLast; |
| 149 | + $this->revCountPart = $this->revCount - $this->revCountLast; |
| 150 | + |
| 151 | + if ( $deltaAll ) { |
137 | 152 | $portion = $this->revCount / $this->maxCount; |
138 | | - $eta = $this->startTime + $delta / $portion; |
| 153 | + $eta = $this->startTime + $deltaAll / $portion; |
139 | 154 | $etats = wfTimestamp( TS_DB, intval( $eta ) ); |
140 | | - $fetchrate = 100.0 * $this->prefetchCount / $this->fetchCount; |
| 155 | + if ( $this->fetchCount ) { |
| 156 | + $fetchRate = 100.0 * $this->prefetchCount / $this->fetchCount; |
| 157 | + } |
| 158 | + else { |
| 159 | + $fetchRate = '-'; |
| 160 | + } |
| 161 | + $pageRate = $this->pageCount / $deltaAll; |
| 162 | + $revRate = $this->revCount / $deltaAll; |
141 | 163 | } else { |
142 | | - $rate = '-'; |
143 | | - $revrate = '-'; |
| 164 | + $pageRate = '-'; |
| 165 | + $revRate = '-'; |
144 | 166 | $etats = '-'; |
145 | | - $fetchrate = '-'; |
| 167 | + $fetchRate = '-'; |
146 | 168 | } |
147 | | - $this->progress( sprintf( "%s: %s %d pages (%0.3f/sec), %d revs (%0.3f/sec), %0.1f%% prefetched, ETA %s [max %d]", |
148 | | - $now, wfWikiID(), $this->pageCount, $rate, $this->revCount, $revrate, $fetchrate, $etats, $this->maxCount ) ); |
| 169 | + if ( $deltaPart ) { |
| 170 | + if ( $this->fetchCountLast ) { |
| 171 | + $fetchRatePart = 100.0 * $this->prefetchCountLast / $this->fetchCountLast; |
| 172 | + } |
| 173 | + else { |
| 174 | + $fetchRatePart = '-'; |
| 175 | + } |
| 176 | + $pageRatePart = $this->pageCountPart / $deltaPart; |
| 177 | + $revRatePart = $this->revCountPart / $deltaPart; |
| 178 | + |
| 179 | + } else { |
| 180 | + $fetchRatePart = '-'; |
| 181 | + $pageRatePart = '-'; |
| 182 | + $revRatePart = '-'; |
| 183 | + } |
| 184 | + $this->progress( sprintf( "%s: %s (ID %d) %d pages (%0.1f|%0.1f/sec all|curr), %d revs (%0.1f|%0.1f/sec all|curr), %0.1f%%|%0.1f%% prefetched (all|curr), ETA %s [max %d]",- |
| 185 | + $now, wfWikiID(), $this->ID, $this->pageCount, $pageRate, $pageRatePart, $this->revCount, $revRate, $revRatePart, $fetchRate, $fetchRatePart, $etats, $this->maxCount ) ); |
| 186 | + $this->lastTime = $now; |
| 187 | + $this->partCountLast = $this->partCount; |
| 188 | + $this->revCountLast = $this->revCount; |
| 189 | + $this->prefetchCountLast = $this->prefetchCount; |
| 190 | + $this->fetchCountLast = $this->fetchCount; |
149 | 191 | } |
150 | 192 | } |
151 | 193 | |
— | — | @@ -452,7 +494,7 @@ |
453 | 495 | (Default: 100) |
454 | 496 | --server=h Force reading from MySQL server h |
455 | 497 | --output=<type>:<file> Write to a file instead of stdout |
456 | | - <type>s: file, gzip, bzip2, 7zip |
| 498 | + <type>s: file, gzip, bzip2, 7zip |
457 | 499 | --current Base ETA on number of pages in database instead of all revisions |
458 | 500 | --spawn Spawn a subprocess for loading text records |
459 | 501 | --help Display this help message |