File tree Expand file tree Collapse file tree
tests/.pest/snapshots/Unit/Result/ToConsoleTest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,10 +60,12 @@ protected function deviationMetric(array $item): DeviationData
6060 $ time = $ this ->result ->values ($ item ['avg ' ], 0 , false );
6161 $ memory = $ this ->result ->values ($ item ['avg ' ], 1 , false );
6262
63+ $ avg = $ this ->metric ($ item , 'avg ' );
64+
6365 return new DeviationData (
6466 percent: $ this ->metricData (
65- $ this ->deviation ($ time ),
66- $ this ->deviation ($ memory ),
67+ $ this ->percentage ( $ avg -> time , $ this -> deviation ($ time) ),
68+ $ this ->percentage ( $ avg -> memory , $ this -> deviation ($ memory) ),
6769 ),
6870 );
6971 }
@@ -99,4 +101,17 @@ protected function deviation(array $values): float
99101
100102 return sqrt (array_sum ($ values ) / count ($ values ));
101103 }
104+
105+ protected function percentage (float $ value1 , float $ value2 ): float
106+ {
107+ if (! $ value1 && ! $ value2 ) {
108+ return 0 ;
109+ }
110+
111+ if ($ value1 === 0.0 ) {
112+ return INF ;
113+ }
114+
115+ return ($ value2 / $ value1 ) * 100 ;
116+ }
102117}
Original file line number Diff line number Diff line change @@ -102,9 +102,9 @@ protected function value(MetricData $metric): string
102102
103103 protected function deviation (float $ value ): string
104104 {
105- $ value = round ($ value , 6 );
105+ $ value = round ($ value , 2 );
106106
107- return ($ value > 0 ? '+ ' : '' ) . $ value ;
107+ return ($ value > 0 ? '+ ' : '' ) . $ value . ' % ' ;
108108 }
109109
110110 protected function time (float $ value ): float
Original file line number Diff line number Diff line change 1212+ ------------------ + ------------------------------ -+ ------------------------------ +
1313| order | 2 | 1 |
1414+ ------------------ + ------------------------------ -+ ------------------------------ +
15- | deviation time | 0 | 0 |
16- | deviation memory | 0 | 0 |
15+ | deviation time | 0 % | 0 % |
16+ | deviation memory | 0 % | 0 % |
1717+ ------------------ + ------------------------------ -+ ------------------------------ +
You can’t perform that action at this time.
0 commit comments