File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
site/frontend/src/pages/compare Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,22 @@ export function computeTestCasesWithNonRelevant(
90
90
. map ( ( c : CompileBenchmarkComparison ) : TestCase => {
91
91
const datumA = c . statistics [ 0 ] ;
92
92
const datumB = c . statistics [ 1 ] ;
93
- const percent = 100 * ( ( datumB - datumA ) / datumA ) ;
93
+
94
+ // In the vast majority of cases, we can do the proportional change calculation. However, some
95
+ // metrics can be zero. If the initial value is 0, we can't compute the new value as a
96
+ // percentage change of the old one. If both values are 0, we can say the change is also 0%.
97
+ // If the new value is not 0, the percentage is not really meaningful, but we can say it's 100%.
98
+ let percent ;
99
+ if ( datumA === 0 ) {
100
+ if ( datumB === 0 ) {
101
+ percent = 0 ;
102
+ } else {
103
+ percent = 100 ;
104
+ }
105
+ } else {
106
+ percent = 100 * ( ( datumB - datumA ) / datumA ) ;
107
+ }
108
+
94
109
return {
95
110
benchmark : c . benchmark ,
96
111
profile : c . profile ,
You can’t perform that action at this time.
0 commit comments