Index: trunk/phase3/includes/profiler/ProfilerSimple.php |
— | — | @@ -12,10 +12,20 @@ |
13 | 13 | class ProfilerSimple extends Profiler { |
14 | 14 | var $mMinimumTime = 0; |
15 | 15 | |
| 16 | + var $zeroEntry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); |
| 17 | + var $errorEntry; |
| 18 | + |
16 | 19 | function __construct( $params ) { |
17 | 20 | global $wgRequestTime, $wgRUstart; |
18 | 21 | parent::__construct( $params ); |
| 22 | + |
| 23 | + $this->errorEntry = $this->zeroEntry; |
| 24 | + $this->errorEntry['count'] = 1; |
| 25 | + |
19 | 26 | if (!empty($wgRequestTime) && !empty($wgRUstart)) { |
| 27 | + # Remove the -total entry from parent::__construct |
| 28 | + $this->mWorkStack = array(); |
| 29 | + |
20 | 30 | $this->mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); |
21 | 31 | |
22 | 32 | $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart); |
— | — | @@ -23,7 +33,7 @@ |
24 | 34 | |
25 | 35 | $entry =& $this->mCollated["-setup"]; |
26 | 36 | if (!is_array($entry)) { |
27 | | - $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); |
| 37 | + $entry = $this->zeroEntry; |
28 | 38 | $this->mCollated["-setup"] =& $entry; |
29 | 39 | } |
30 | 40 | $entry['cpu'] += $elapsedcpu; |
— | — | @@ -62,20 +72,18 @@ |
63 | 73 | $message = "Profile section ended by close(): {$ofname}"; |
64 | 74 | $functionname = $ofname; |
65 | 75 | $this->debug( "$message\n" ); |
66 | | - $this->mCollated[$message] = array( |
67 | | - 'real' => 0.0, 'count' => 1); |
| 76 | + $this->mCollated[$message] = $this->errorEntry; |
68 | 77 | } |
69 | 78 | elseif ($ofname != $functionname) { |
70 | 79 | $message = "Profiling error: in({$ofname}), out($functionname)"; |
71 | 80 | $this->debug( "$message\n" ); |
72 | | - $this->mCollated[$message] = array( |
73 | | - 'real' => 0.0, 'count' => 1); |
| 81 | + $this->mCollated[$message] = $this->errorEntry; |
74 | 82 | } |
75 | 83 | $entry =& $this->mCollated[$functionname]; |
76 | 84 | $elapsedcpu = $this->getCpuTime() - $octime; |
77 | 85 | $elapsedreal = microtime(true) - $ortime; |
78 | 86 | if (!is_array($entry)) { |
79 | | - $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); |
| 87 | + $entry = $this->zeroEntry; |
80 | 88 | $this->mCollated[$functionname] =& $entry; |
81 | 89 | } |
82 | 90 | $entry['cpu'] += $elapsedcpu; |