Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tools/parse_baselines/providers/snapshot_restore.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 snapshot restore 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 SnapshotRestoreDataParser(DataParser):
20
"""Parse the data provided by the snapshot restore 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
"restore_latency/P50",
27
"restore_latency/P90",
28
])
29
30
# pylint: disable=R0201
31
def calculate_baseline(self, data: List[float]) -> dict:
32
"""Return the target and delta values, given a list of data points."""
33
avg = statistics.mean(data)
34
stddev = statistics.stdev(data)
35
return {
36
'target': math.ceil(round(avg, 2)),
37
'delta_percentage':
38
math.ceil(3 * stddev/avg * 100) + DELTA_EXTRA_MARGIN
39
}
40
41