test: Use INFINITY & NaN for intermediate metrics
As MIN_VALUE is the smallest positive value IEEE 754 allows,
computeStats() returns an incorrect maximum value when it receives a set
of metrics that are all 0 so replace MIN_VALUE with NEGATIVE_INFINITY.
For consistency and clarity, use the corresponding POSITIVE_INFINITY and
NaN to respectively initialize the minimum value and median value; as
the function assumes that it received at least one item by dividing by
(values.size() - 1), these values should never be returned by the
function.
Test: atest MicrodroidBenchmarks#testMicrodroidDebugBootTime
Change-Id: I9368a7d3de59d20f7b55b03520e07d2509ab13b7
diff --git a/tests/helper/src/java/com/android/microdroid/test/common/MetricsProcessor.java b/tests/helper/src/java/com/android/microdroid/test/common/MetricsProcessor.java
index 42eb6a1..dd68d6a 100644
--- a/tests/helper/src/java/com/android/microdroid/test/common/MetricsProcessor.java
+++ b/tests/helper/src/java/com/android/microdroid/test/common/MetricsProcessor.java
@@ -50,8 +50,8 @@
Collections.sort(values);
double sum = 0;
- double min = Double.MAX_VALUE;
- double max = Double.MIN_VALUE;
+ double min = Double.POSITIVE_INFINITY;
+ double max = Double.NEGATIVE_INFINITY;
for (Double d : values) {
sum += d;
if (min > d) min = d;
@@ -63,7 +63,7 @@
sqSum += (d - avg) * (d - avg);
}
double stdDev = Math.sqrt(sqSum / (values.size() - 1));
- double median = Double.MIN_VALUE;
+ double median = Double.NaN;
if (values.size() > 0) {
int rank = values.size() / 2;
if (values.size() % 2 == 0) {