Index: trunk/phase3/includes/ProfilerSimpleTrace.php |
— | — | @@ -21,49 +21,48 @@ |
22 | 22 | |
23 | 23 | function __construct() { |
24 | 24 | global $wgRequestTime, $wgRUstart; |
25 | | - if (!empty($wgRequestTime) && !empty($wgRUstart)) { |
26 | | - $this->mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); |
27 | | - $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart); |
28 | | - $elapsedreal = microtime(true) - $wgRequestTime; |
| 25 | + if ( !empty( $wgRequestTime ) && !empty( $wgRUstart ) ) { |
| 26 | + $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, $this->getCpuTime( $wgRUstart ) ); |
29 | 27 | } |
30 | 28 | $this->trace .= "Beginning trace: \n"; |
31 | 29 | } |
32 | 30 | |
33 | 31 | function profileIn($functionname) { |
34 | 32 | $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); |
35 | | - $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n"; |
| 33 | + $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . |
| 34 | + str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n"; |
36 | 35 | } |
37 | 36 | |
38 | 37 | function profileOut($functionname) { |
39 | 38 | global $wgDebugFunctionEntry; |
40 | 39 | |
41 | | - if ($wgDebugFunctionEntry) { |
| 40 | + if ( $wgDebugFunctionEntry ) { |
42 | 41 | $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); |
43 | 42 | } |
44 | 43 | |
45 | | - list($ofname, /* $ocount */ ,$ortime,$octime) = array_pop($this->mWorkStack); |
| 44 | + list( $ofname, /* $ocount */ , $ortime, $octime ) = array_pop( $this->mWorkStack ); |
46 | 45 | |
47 | | - if (!$ofname) { |
| 46 | + if ( !$ofname ) { |
48 | 47 | $this->trace .= "Profiling error: $functionname\n"; |
49 | 48 | } else { |
50 | | - if ($functionname == 'close') { |
| 49 | + if ( $functionname == 'close' ) { |
51 | 50 | $message = "Profile section ended by close(): {$ofname}"; |
52 | 51 | $functionname = $ofname; |
53 | 52 | $this->trace .= $message . "\n"; |
54 | 53 | } |
55 | | - elseif ($ofname != $functionname) { |
| 54 | + elseif ( $ofname != $functionname ) { |
56 | 55 | $this->trace .= "Profiling error: in({$ofname}), out($functionname)"; |
57 | 56 | } |
58 | | - $elapsedcpu = $this->getCpuTime() - $octime; |
59 | | - $elapsedreal = microtime(true) - $ortime; |
60 | | - $this->trace .= sprintf("%03.6f %6.1f",$elapsedreal,$this->memoryDiff()) . str_repeat(" ",count($this->mWorkStack)+1) . " < " . $functionname . "\n"; |
| 57 | + $elapsedreal = microtime( true ) - $ortime; |
| 58 | + $this->trace .= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) . |
| 59 | + str_repeat(" ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; |
61 | 60 | } |
62 | 61 | } |
63 | 62 | |
64 | 63 | function memoryDiff() { |
65 | 64 | $diff = memory_get_usage() - $this->memory; |
66 | 65 | $this->memory = memory_get_usage(); |
67 | | - return $diff/1024; |
| 66 | + return $diff / 1024; |
68 | 67 | } |
69 | 68 | |
70 | 69 | function getOutput() { |