Index: trunk/phase3/includes/ProfilerSimple.php |
— | — | @@ -14,12 +14,17 @@ |
15 | 15 | function ProfilerSimple() { |
16 | 16 | global $wgRequestTime,$wgRUstart; |
17 | 17 | if (!empty($wgRequestTime) && !empty($wgRUstart)) { |
18 | | - $this->mWorkStack[] = array( '-total', 0, $this->getTime($wgRequestTime),$this->getCpuTime($wgRUstart)); |
| 18 | + $this->mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); |
19 | 19 | |
20 | 20 | $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart); |
21 | | - $elapsedreal = $this->getTime() - $this->getTime($wgRequestTime); |
| 21 | + $elapsedreal = microtime(true) - $wgRequestTime; |
22 | 22 | |
23 | 23 | $entry =& $this->mCollated["-setup"]; |
| 24 | + if (!is_array($entry)) { |
| 25 | + $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); |
| 26 | + $this->mCollated[$functionname] =& $entry; |
| 27 | + |
| 28 | + } |
24 | 29 | $entry['cpu'] += $elapsedcpu; |
25 | 30 | $entry['cpu_sq'] += $elapsedcpu*$elapsedcpu; |
26 | 31 | $entry['real'] += $elapsedreal; |
— | — | @@ -33,7 +38,7 @@ |
34 | 39 | if ($wgDebugFunctionEntry) { |
35 | 40 | $this->debug(str_repeat(' ', count($this->mWorkStack)).'Entering '.$functionname."\n"); |
36 | 41 | } |
37 | | - $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), $this->getTime(), $this->getCpuTime()); |
| 42 | + $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); |
38 | 43 | } |
39 | 44 | |
40 | 45 | function profileOut($functionname) { |
— | — | @@ -60,10 +65,13 @@ |
61 | 66 | $this->debug( "$message\n" ); |
62 | 67 | } |
63 | 68 | $entry =& $this->mCollated[$functionname]; |
64 | | - |
65 | 69 | $elapsedcpu = $this->getCpuTime() - $octime; |
66 | | - $elapsedreal = $this->getTime() - $ortime; |
67 | | - |
| 70 | + $elapsedreal = microtime(true) - $ortime; |
| 71 | + if (!is_array($entry)) { |
| 72 | + $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); |
| 73 | + $this->mCollated[$functionname] =& $entry; |
| 74 | + |
| 75 | + } |
68 | 76 | $entry['cpu'] += $elapsedcpu; |
69 | 77 | $entry['cpu_sq'] += $elapsedcpu*$elapsedcpu; |
70 | 78 | $entry['real'] += $elapsedreal; |
— | — | @@ -83,9 +91,10 @@ |
84 | 92 | return ($ru['ru_utime.tv_sec']+$ru['ru_stime.tv_sec']+($ru['ru_utime.tv_usec']+$ru['ru_stime.tv_usec'])*1e-6); |
85 | 93 | } |
86 | 94 | |
| 95 | + /* If argument is passed, it assumes that it is dual-format time string, returns proper float time value */ |
87 | 96 | function getTime($time=null) { |
88 | 97 | if ($time==null) |
89 | | - $time=microtime(); |
| 98 | + return microtime(true); |
90 | 99 | list($a,$b)=explode(" ",$time); |
91 | 100 | return (float)($a+$b); |
92 | 101 | } |