Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tools/parse_baselines/providers/iperf3.py
1958 views
1
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
"""Implement the DataParser for iperf3 throughput tests."""
4
5
import statistics
6
import math
7
from collections import Iterator
8
from typing import List
9
from providers.types import DataParser
10
11
# We add a small extra percentage margin, to account for small variations
12
# that were not caught while gathering baselines. This provides
13
# slightly better reliability, while not affecting regression
14
# detection.
15
DELTA_EXTRA_MARGIN = 3
16
17
18
# pylint: disable=R0903
19
class Iperf3DataParser(DataParser):
20
"""Parse the data provided by the iperf3 throughput tests."""
21
22
# pylint: disable=W0102
23
def __init__(self, data_provider: Iterator):
24
"""Initialize the data parser."""
25
super().__init__(data_provider, [
26
"throughput/total",
27
"cpu_utilization_vcpus_total/Avg",
28
"cpu_utilization_vmm/Avg",
29
])
30
31
# pylint: disable=R0201
32
def calculate_baseline(self, data: List[float]) -> dict:
33
"""Return the target and delta values, given a list of data points."""
34
avg = statistics.mean(data)
35
stddev = statistics.stdev(data)
36
return {
37
'target': math.ceil(round(avg, 2)),
38
'delta_percentage':
39
math.ceil(round(3 * stddev/avg * 100, 2)) + DELTA_EXTRA_MARGIN
40
}
41
42