Path: blob/main/tools/parse_baselines/providers/snapshot_restore.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 snapshot restore performance 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 = 4151617# pylint: disable=R090318class SnapshotRestoreDataParser(DataParser):19"""Parse the data provided by the snapshot restore performance tests."""2021# pylint: disable=W010222def __init__(self, data_provider: Iterator):23"""Initialize the data parser."""24super().__init__(data_provider, [25"restore_latency/P50",26"restore_latency/P90",27])2829# pylint: disable=R020130def calculate_baseline(self, data: List[float]) -> dict:31"""Return the target and delta values, given a list of data points."""32avg = statistics.mean(data)33stddev = statistics.stdev(data)34return {35'target': math.ceil(round(avg, 2)),36'delta_percentage':37math.ceil(3 * stddev/avg * 100) + DELTA_EXTRA_MARGIN38}394041