Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tools/parse_baselines/providers/block.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 block device performance 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 = 4
16
17
18
# pylint: disable=R0903
19
class BlockDataParser(DataParser):
20
"""Parse the data provided by the block performance tests."""
21
22
# pylint: disable=W0102
23
def __init__(self, data_provider: Iterator):
24
"""Initialize the data parser."""
25
super().__init__(data_provider, [
26
"iops_read/Avg",
27
"iops_write/Avg",
28
"bw_read/Avg",
29
"bw_write/Avg",
30
"cpu_utilization_vcpus_total/Avg",
31
"cpu_utilization_vmm/Avg",
32
])
33
34
# pylint: disable=R0201
35
def calculate_baseline(self, data: List[float]) -> dict:
36
"""Return the target and delta values, given a list of data points."""
37
avg = statistics.mean(data)
38
stddev = statistics.stdev(data)
39
return {
40
'target': math.ceil(round(avg, 2)),
41
'delta_percentage':
42
math.ceil(3 * stddev/avg * 100) + DELTA_EXTRA_MARGIN
43
}
44
45