@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | * @param array $timer |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function getMemoryString( $timer ) |
|
40 | + public function getMemoryString($timer) |
|
41 | 41 | { |
42 | - $timer = $this->normalize( $timer ); |
|
43 | - return sprintf( '%s %s', round( $timer['memory'] / 1000 ), __( 'kB', 'blackbar' )); |
|
42 | + $timer = $this->normalize($timer); |
|
43 | + return sprintf('%s %s', round($timer['memory'] / 1000), __('kB', 'blackbar')); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param array $timer |
48 | 48 | * @return string |
49 | 49 | */ |
50 | - public function getNameString( $timer ) |
|
50 | + public function getNameString($timer) |
|
51 | 51 | { |
52 | - $timer = $this->normalize( $timer ); |
|
52 | + $timer = $this->normalize($timer); |
|
53 | 53 | return $timer['name']; |
54 | 54 | } |
55 | 55 | |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @param array $timer |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public function getTimeString( $timer ) |
|
60 | + public function getTimeString($timer) |
|
61 | 61 | { |
62 | - $timer = $this->normalize( $timer ); |
|
63 | - $index = array_search( $timer['name'], array_column( $this->timers, 'name' )); |
|
64 | - $start = $this->start + ( $index * $this->noise ); |
|
65 | - $time = number_format( round(( $timer['time'] - $start ) * 1000, 4 ), 4 ); |
|
66 | - return sprintf( '%s %s', $time, __( 'ms', 'blackbar' )); |
|
62 | + $timer = $this->normalize($timer); |
|
63 | + $index = array_search($timer['name'], array_column($this->timers, 'name')); |
|
64 | + $start = $this->start + ($index * $this->noise); |
|
65 | + $time = number_format(round(($timer['time'] - $start) * 1000, 4), 4); |
|
66 | + return sprintf('%s %s', $time, __('ms', 'blackbar')); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getTotalTime() |
73 | 73 | { |
74 | - $totalNoise = ( count( $this->timers ) - 1 ) * $this->noise; |
|
74 | + $totalNoise = (count($this->timers) - 1) * $this->noise; |
|
75 | 75 | return $this->stop - $this->start - $totalNoise; |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $name |
80 | 80 | */ |
81 | - public function trace( $name ) |
|
81 | + public function trace($name) |
|
82 | 82 | { |
83 | - $microtime = microtime( true ); |
|
84 | - if( !$this->start ) { |
|
83 | + $microtime = microtime(true); |
|
84 | + if (!$this->start) { |
|
85 | 85 | $this->start = $microtime; |
86 | 86 | } |
87 | - if( $name === 'blackbar/profiler/noise' ) { |
|
87 | + if ($name === 'blackbar/profiler/noise') { |
|
88 | 88 | $this->noise = $microtime - $this->start; |
89 | 89 | return; |
90 | 90 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - protected function normalize( $timer ) |
|
102 | + protected function normalize($timer) |
|
103 | 103 | { |
104 | - return wp_parse_args( (array) $timer, array( |
|
104 | + return wp_parse_args((array) $timer, array( |
|
105 | 105 | 'name' => '', |
106 | 106 | 'time' => 0, |
107 | 107 | 'memory' => 0, |