Path: blob/main/tools/parse_baselines/providers/iperf3.py
1958 views
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""Implement the DataParser for iperf3 throughput tests."""34import statistics5import math6from collections import Iterator7from typing import List8from providers.types import DataParser910# We add a small extra percentage margin, to account for small variations11# that were not caught while gathering baselines. This provides12# slightly better reliability, while not affecting regression13# detection.14DELTA_EXTRA_MARGIN = 3151617# pylint: disable=R090318class Iperf3DataParser(DataParser):19"""Parse the data provided by the iperf3 throughput tests."""2021# pylint: disable=W010222def __init__(self, data_provider: Iterator):23"""Initialize the data parser."""24super().__init__(data_provider, [25"throughput/total",26"cpu_utilization_vcpus_total/Avg",27"cpu_utilization_vmm/Avg",28])2930# pylint: disable=R020131def calculate_baseline(self, data: List[float]) -> dict:32"""Return the target and delta values, given a list of data points."""33avg = statistics.mean(data)34stddev = statistics.stdev(data)35return {36'target': math.ceil(round(avg, 2)),37'delta_percentage':38math.ceil(round(3 * stddev/avg * 100, 2)) + DELTA_EXTRA_MARGIN39}404142