Best Python code snippet using pytest-benchmark
storage.py
Source:storage.py
...101 }102 }103 return self._es.search(index=self._es_index, doc_type=self._es_doctype, body=body)104 @staticmethod105 def _benchmark_from_es_record(source_es_record):106 result = {}107 for benchmark_key in ("group", "stats", "options", "param", "name", "params", "fullname", "benchmark_id"):108 result[benchmark_key] = source_es_record[benchmark_key]109 return result110 @staticmethod111 def _run_info_from_es_record(source_es_record):112 result = {}113 for run_key in ("machine_info", "commit_info", "datetime", "version"):114 result[run_key] = source_es_record[run_key]115 return result116 def _group_by_commit_and_time(self, hits):117 result = {}118 for hit in hits:119 source_hit = hit["_source"]120 key = "%s_%s" % (source_hit["commit_info"]["id"], source_hit["datetime"])121 benchmark = self._benchmark_from_es_record(source_hit)122 if key in result:123 result[key]["benchmarks"].append(benchmark)124 else:125 run_info = self._run_info_from_es_record(source_hit)126 run_info["benchmarks"] = [benchmark]127 result[key] = run_info128 return result129 def load_benchmarks(self, *args):130 """131 Yield benchmarks that corresponds with project. Put path and132 source (uncommon part of path) to benchmark dict.133 """134 id_prefix = args[0] if args else None135 r = self._search(self._project_name, id_prefix)136 for hit in r["hits"]["hits"]:137 bench = self._benchmark_from_es_record(hit["_source"])138 bench.update(bench.pop("stats"))139 bench["source"] = bench["benchmark_id"]140 yield bench141 def save(self, output_json, save):142 output_benchmarks = output_json.pop("benchmarks")143 for bench in output_benchmarks:144 # add top level info from output_json dict to each record145 bench.update(output_json)146 benchmark_id = save147 if self.default_machine_id:148 benchmark_id = self.default_machine_id + "_" + benchmark_id149 doc_id = benchmark_id + "_" + bench["fullname"]150 bench["benchmark_id"] = benchmark_id151 self._es.index(...
elasticsearch.py
Source:elasticsearch.py
...101 }102 }103 return self._es.search(index=self._es_index, doc_type=self._es_doctype, body=body)104 @staticmethod105 def _benchmark_from_es_record(source_es_record):106 result = {}107 for benchmark_key in ("group", "stats", "options", "param", "name", "params", "fullname", "benchmark_id"):108 result[benchmark_key] = source_es_record[benchmark_key]109 return result110 @staticmethod111 def _run_info_from_es_record(source_es_record):112 result = {}113 for run_key in ("machine_info", "commit_info", "datetime", "version"):114 result[run_key] = source_es_record[run_key]115 return result116 def _group_by_commit_and_time(self, hits):117 result = {}118 for hit in hits:119 source_hit = hit["_source"]120 key = "%s_%s" % (source_hit["commit_info"]["id"], source_hit["datetime"])121 benchmark = self._benchmark_from_es_record(source_hit)122 if key in result:123 result[key]["benchmarks"].append(benchmark)124 else:125 run_info = self._run_info_from_es_record(source_hit)126 run_info["benchmarks"] = [benchmark]127 result[key] = run_info128 return result129 def load_benchmarks(self, *args):130 """131 Yield benchmarks that corresponds with project. Put path and132 source (uncommon part of path) to benchmark dict.133 """134 id_prefix = args[0] if args else None135 r = self._search(self._project_name, id_prefix)136 for hit in r["hits"]["hits"]:137 bench = self._benchmark_from_es_record(hit["_source"])138 bench.update(bench.pop("stats"))139 bench["source"] = bench["benchmark_id"]140 yield bench141 def save(self, output_json, save):142 output_benchmarks = output_json.pop("benchmarks")143 for bench in output_benchmarks:144 # add top level info from output_json dict to each record145 bench.update(output_json)146 benchmark_id = save147 if self.default_machine_id:148 benchmark_id = self.default_machine_id + "_" + benchmark_id149 doc_id = benchmark_id + "_" + bench["fullname"]150 bench["benchmark_id"] = benchmark_id151 self._es.index(...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!