def load(self, id_prefix=None): """ Yield key and content of records that corresponds with project name. """ r = self._search(self._project_name, id_prefix) groupped_data = self._group_by_commit_and_time(r["hits"]["hits"]) result = [(key, value) for key, value in groupped_data.items()] result.sort(key=lambda x: datetime.strptime(x[1]["datetime"], "%Y-%m-%dT%H:%M:%S.%f")) for key, data in result: for bench in data["benchmarks"]: normalize_stats(bench["stats"]) yield key, data
from pytest_benchmark.utils import NAME_FORMATTERS from pytest_benchmark.utils import DifferenceRegressionCheck from pytest_benchmark.utils import Path from pytest_benchmark.utils import PercentageRegressionCheck from pytest_benchmark.utils import get_machine_id pytest_plugins = "pytester" THIS = py.path.local(__file__) STORAGE = THIS.dirpath(THIS.purebasename) JSON_DATA = json.loads(STORAGE.listdir('0030_*.json')[0].read_text(encoding='utf8')) JSON_DATA["machine_info"] = {'foo': 'bar'} JSON_DATA["commit_info"] = {'foo': 'bar'} list(normalize_stats(bench['stats']) for bench in JSON_DATA["benchmarks"]) class Namespace(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __getitem__(self, item): return self.__dict__[item] def getoption(self, item, default=None): try: return self[item] except KeyError: return default
from pytest_benchmark.storage.file import FileStorage from pytest_benchmark.utils import NAME_FORMATTERS from pytest_benchmark.utils import DifferenceRegressionCheck from pytest_benchmark.utils import PercentageRegressionCheck from pytest_benchmark.utils import get_machine_id pytest_plugins = "pytester" THIS = py.path.local(__file__) STORAGE = THIS.dirpath(THIS.purebasename) JSON_DATA = json.load(STORAGE.listdir('0030_*.json')[0].open()) JSON_DATA["machine_info"] = {'foo': 'bar'} JSON_DATA["commit_info"] = {'foo': 'bar'} list(normalize_stats(bench['stats']) for bench in JSON_DATA["benchmarks"]) class Namespace(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __getitem__(self, item): return self.__dict__[item] def getoption(self, item, default=None): try: return self[item] except KeyError: return default