parse_baselines: fix LatencyDataParser
Use the 3-sigma rule for determining the delta percentage for the
latency values.
Also add the pkt_loss statistic to the parsing.
"""Implement the DataParser for network latency performance tests."""
import statistics
+import math
from collections.abc import Iterator
from typing import List
from providers.types import DataParser
@@ -11,7 +12,7 @@ from providers.types import DataParser
# that were not caught while gathering baselines. This provides
# slightly better reliability, while not affecting regression
# detection.
-DELTA_EXTRA_MARGIN = 0.01
+DELTA_EXTRA_MARGIN = 0.1
# pylint: disable=R0903
@@ -23,14 +24,18 @@ class LatencyDataParser(DataParser):
"""Initialize the data parser."""
super().__init__(
data_provider,
- ["latency/Avg"],
+ ["latency/Avg", "pkt_loss/Avg"],
)
def calculate_baseline(self, data: List[float]) -> dict:
"""Return the target and delta values, given a list of data points."""
avg = statistics.mean(data)
stddev = statistics.stdev(data)
+ if math.isclose(0.0, avg):
+ delta_percentage = 0.0
+ else:
+ delta_percentage = math.ceil(3 * stddev / avg * 100)
return {
"target": round(avg, 3),
- "delta_percentage": round(stddev + DELTA_EXTRA_MARGIN, 2),
+ "delta_percentage": delta_percentage + DELTA_EXTRA_MARGIN,
}
