Index: trunk/phase3/includes/profiler/Profiler.php |
— | — | @@ -41,20 +41,21 @@ |
42 | 42 | private static $__instance = null; |
43 | 43 | |
44 | 44 | function __construct( $params ) { |
45 | | - // Push an entry for the pre-profile setup time onto the stack |
46 | | - global $wgRequestTime; |
47 | | - if ( !empty( $wgRequestTime ) ) { |
48 | | - $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, 0 ); |
49 | | - $this->mStack[] = array( '-setup', 1, $wgRequestTime, 0, microtime(true), 0 ); |
50 | | - } else { |
51 | | - $this->profileIn( '-total' ); |
52 | | - } |
53 | 45 | if ( isset( $params['timeMetric'] ) ) { |
54 | 46 | $this->mTimeMetric = $params['timeMetric']; |
55 | 47 | } |
56 | 48 | if ( isset( $params['profileID'] ) ) { |
57 | 49 | $this->mProfileID = $params['profileID']; |
58 | 50 | } |
| 51 | + |
| 52 | + // Push an entry for the pre-profile setup time onto the stack |
| 53 | + $initial = $this->getInitialTime(); |
| 54 | + if ( $initial !== null ) { |
| 55 | + $this->mWorkStack[] = array( '-total', 0, $initial, 0 ); |
| 56 | + $this->mStack[] = array( '-setup', 1, $initial, 0, $this->getTime(), 0 ); |
| 57 | + } else { |
| 58 | + $this->profileIn( '-total' ); |
| 59 | + } |
59 | 60 | } |
60 | 61 | |
61 | 62 | /** |
— | — | @@ -274,6 +275,24 @@ |
275 | 276 | return $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6; |
276 | 277 | } |
277 | 278 | |
| 279 | + private function getInitialTime() { |
| 280 | + global $wgRequestTime, $wgRUstart; |
| 281 | + |
| 282 | + if ( $this->mTimeMetric === 'user' ) { |
| 283 | + if ( count( $wgRUstart ) ) { |
| 284 | + return $wgRUstart['ru_utime.tv_sec'] + $wgRUstart['ru_utime.tv_usec'] / 1e6; |
| 285 | + } else { |
| 286 | + return null; |
| 287 | + } |
| 288 | + } else { |
| 289 | + if ( empty( $wgRequestTime ) ) { |
| 290 | + return null; |
| 291 | + } else { |
| 292 | + return $wgRequestTime; |
| 293 | + } |
| 294 | + } |
| 295 | + } |
| 296 | + |
278 | 297 | protected function collateData() { |
279 | 298 | if ( $this->mCollateDone ) { |
280 | 299 | return; |