summaryrefslogtreecommitdiff
path: root/buildscripts/benchmarks/config.py
blob: 3fd6467fb67812b9e4526dbcb4f6349f3a52d03d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Google Benchmarks analyzer config."""
import os
from typing import Dict, Union

import yaml

THRESHOLD_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "threshold_config.yml")


def get_thresholds(suite: str) -> Dict[str, Union[int, float]]:
    """Get thresholds configured in  yaml file."""

    with open(THRESHOLD_CONFIG) as fh:
        cfg = yaml.safe_load(fh)

    thresholds = cfg["defaults"]
    overrides = cfg["overrides"].get(suite)
    if overrides:
        for key, value in overrides.items():
            thresholds[key] = value

    return thresholds