@@ -70,6 +70,10 @@ |
||
70 | 70 | /* |
71 | 71 | * Test if class is loaded |
72 | 72 | */ |
73 | + |
|
74 | + /** |
|
75 | + * @param string $word |
|
76 | + */ |
|
73 | 77 | public function saySomething($word) { |
74 | 78 | echo $word; |
75 | 79 | } |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | public function renderTimestampAsTable($timestamps, $memoryPeak, $pageLoadTime) { |
21 | 21 | $prev = $first = $timestamps[0]['when']; |
22 | 22 | $last = $timestamps[count($timestamps) - 1]['when']; |
23 | - if($last === $first) { |
|
23 | + if ($last === $first) { |
|
24 | 24 | $last = microtime(true); |
25 | 25 | } |
26 | 26 | $html = "<div class='log' style='background-color:#fff; color:#000; margin-top:50px; padding:20px;'><table class=table><h2>Timestamps</h2><tr><th>Domain</th><th>Where</th><th>When (sec)</th><th>Duration (sec)</th><th>Percent</th><th>Memory (MB)</th><th>Memory peak (MB)</th><th>Comment</th></tr>"; |
27 | 27 | $right = ' style="text-align: right;"'; |
28 | 28 | $total = array('domain' => array(), 'where' => array()); |
29 | - foreach($timestamps as $val) { |
|
29 | + foreach ($timestamps as $val) { |
|
30 | 30 | $when = $val['when'] - $first; |
31 | - $duration = isset($val['duration']) ? round($val['duration'], 3) : null; |
|
31 | + $duration = isset($val['duration']) ? round($val['duration'], 3) : null; |
|
32 | 32 | $percent = round(($when) / ($last - $first) * 100); |
33 | 33 | $memory = round($val['memory'] / 1024 / 1024, 2); |
34 | 34 | $peak = isset($val['memory-peak']) ? round($val['memory-peak'] / 1024 / 1024, 2) : NULL; |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | } |
41 | 41 | $html .= "</table><table class=table><h2>Duration per domain</h2><tr><th>Domain</th><th>Duration</th><th>Percent</th></tr>"; |
42 | 42 | arsort($total['domain']); |
43 | - foreach($total['domain'] as $key => $val) { |
|
43 | + foreach ($total['domain'] as $key => $val) { |
|
44 | 44 | $percent = round($val / ($last - $first) * 100, 1); |
45 | 45 | $html .= "<tr><td>{$key}</td><td>{$val}</td><td>{$percent}</td></tr>"; |
46 | 46 | } |
47 | 47 | $html .= "</table><table class=table><h2>Duration per area</h2><tr><th>Area</th><th>Duration</th><th>Percent</th></tr>"; |
48 | 48 | arsort($total['where']); |
49 | - foreach($total['where'] as $key => $val) { |
|
49 | + foreach ($total['where'] as $key => $val) { |
|
50 | 50 | $percent = round($val / ($last - $first) * 100, 1); |
51 | 51 | $html .= "<tr><td>{$key}</td><td>{$val}</td><td>{$percent}</td></tr>"; |
52 | 52 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $timestamps = $log->getTimestamp(); |
26 | 26 | $testMemoryPeak = 1; |
27 | 27 | $testPageLoadTime = 2; |
28 | - $res = $table->renderTimestampAsTable( $timestamps, $testMemoryPeak, $testPageLoadTime ); |
|
28 | + $res = $table->renderTimestampAsTable($timestamps, $testMemoryPeak, $testPageLoadTime); |
|
29 | 29 | |
30 | 30 | $this->assertInternalType('string', $res); |
31 | 31 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * |
54 | 54 | */ |
55 | 55 | public function getTimestamp() { |
56 | - return $this->timestamp; |
|
56 | + return $this->timestamp; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $comment on the timestamp. |
34 | 34 | * |
35 | 35 | */ |
36 | - public function Timestamp($domain, $where, $comment=null) { |
|
36 | + public function Timestamp($domain, $where, $comment = null) { |
|
37 | 37 | $now = microtime(true); |
38 | 38 | $this->timestamp[] = array( |
39 | 39 | 'domain' => $domain, |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'when' => $now, |
43 | 43 | 'memory' => memory_get_usage(true), |
44 | 44 | ); |
45 | - if($this->pos) { |
|
45 | + if ($this->pos) { |
|
46 | 46 | $this->timestamp[$this->pos - 1]['memory-peak'] = memory_get_peak_usage(true); |
47 | 47 | $this->timestamp[$this->pos - 1]['duration'] = $now - $this->timestamp[$this->pos - 1]['when']; |
48 | 48 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * Timestamp, log a event with a time. |
33 | 33 | * |
34 | 34 | */ |
35 | - public function Timestamp($domain, $where, $comment=null) { |
|
35 | + public function Timestamp($domain, $where, $comment = null) { |
|
36 | 36 | $this->log->Timestamp($domain, $where, $comment); |
37 | 37 | } |
38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function printLog() { |
45 | 45 | $timestamps = $this->log->getTimestamp(); |
46 | 46 | |
47 | - if(empty($timestamps)) { |
|
47 | + if (empty($timestamps)) { |
|
48 | 48 | return $this->table->nothingLogged(); |
49 | 49 | } |
50 | 50 |