# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Implement the DataParser for snapshot restore performance tests."""

import statistics
import math
from collections.abc import Iterator
from typing import List
from providers.types import DataParser

# We add a small extra percentage margin, to account for small variations
# that were not caught while gathering baselines. This provides
# slightly better reliability, while not affecting regression
# detection.
DELTA_EXTRA_MARGIN = 4


# pylint: disable=R0903
class SnapshotRestoreDataParser(DataParser):
    """Parse the data provided by the snapshot restore performance tests."""

    # pylint: disable=W0102
    def __init__(self, data_provider: Iterator):
        """Initialize the data parser."""
        super().__init__(
            data_provider,
            [
                "latency/P50",
                "latency/P90",
            ],
        )

    def calculate_baseline(self, data: List[float]) -> dict:
        """Return the target and delta values, given a list of data points."""
        avg = statistics.mean(data)
        stddev = statistics.stdev(data)
        return {
            "target": round(avg, 3),
            "delta_percentage": math.ceil(3 * stddev / avg * 100) + DELTA_EXTRA_MARGIN,
        }

@@ -546,9 +546,9 @@
 N = 
-4
+6
 %0A%0A%0A#
@@ -1155,40 +1155,190 @@
     
-stddev = statistics.stdev(da
+min_ = min(data)%0A        max_ = max(data)%0A%0A        min_delta = 100 * abs(avg - min_) / avg%0A        max_delta = 100 * abs(avg - max_) / avg%0A        delta = max(max_delta, min_del
 ta)%0A
+%0A
     
@@ -1433,30 +1433,13 @@
 eil(
-3 * stddev / avg * 100
+delta
 ) + 

change the way we calculate baselines