How to use hd15iqr method in pytest-benchmark

Best Python code snippet using pytest-benchmark

stats.py

Source:stats.py Github

copy

Full Screen

...73 return self.data[0]74 else:75 return self.sorted_data[bisect_left(self.sorted_data, self.q1 - 1.5 * self.iqr)]76 @cached_property77 def hd15iqr(self):78 """79 Tukey-style Highest Datum within 1.5 IQR over Q3.80 """81 if len(self.data) == 1:82 return self.data[0]83 else:84 pos = bisect_right(self.sorted_data, self.q3 + 1.5 * self.iqr)85 if pos == len(self.data):86 return self.sorted_data[-1]87 else:88 return self.sorted_data[pos]89 @cached_property90 def q1(self):91 rounds = self.rounds...

Full Screen

Full Screen

histogram.py

Source:histogram.py Github

copy

Full Screen

1import py2from .compat import Iterable3from .utils import TIME_UNITS4from .utils import slugify5try:6 from pygal.graph.box import Box7 from pygal.style import DefaultStyle8except ImportError as exc:9 raise ImportError(exc.args, "Please install pygal and pygaljs or pytest-benchmark[histogram]")10class CustomBox(Box):11 def _box_points(self, serie, _):12 return serie, [serie[0], serie[6]]13 def _value_format(self, x):14 return "Min: {0[0]:.4f}\n" \15 "Q1-1.5IQR: {0[1]:.4f}\n" \16 "Q1: {0[2]:.4f}\nMedian: {0[3]:.4f}\nQ3: {0[4]:.4f}\n" \17 "Q3+1.5IQR: {0[5]:.4f}\n" \18 "Max: {0[6]:.4f}".format(x[:7])19 def _format(self, x, *args):20 sup = super(CustomBox, self)._format21 if args:22 val = x.values23 else:24 val = x25 if isinstance(val, Iterable):26 return self._value_format(val), val[7]27 else:28 return sup(x, *args)29 def _tooltip_data(self, node, value, x, y, classes=None, xlabel=None):30 super(CustomBox, self)._tooltip_data(node, value[0], x, y, classes=classes, xlabel=None)31 self.svg.node(node, 'desc', class_="x_label").text = value[1]32def make_plot(benchmarks, title, adjustment):33 class Style(DefaultStyle):34 colors = ["#000000" if row["path"] else DefaultStyle.colors[1]35 for row in benchmarks]36 font_family = 'Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace'37 minimum = int(min(row["min"] * adjustment for row in benchmarks))38 maximum = int(max(39 min(row["max"], row["hd15iqr"]) * adjustment40 for row in benchmarks41 ) + 1)42 try:43 import pygaljs44 except ImportError:45 opts = {}46 else:47 opts = {48 "js": [49 pygaljs.uri("2.0.x", "pygal-tooltips.js")50 ]51 }52 plot = CustomBox(53 box_mode='tukey',54 x_label_rotation=-90,55 x_labels=["{0[name]}".format(row) for row in benchmarks],56 show_legend=False,57 title=title,58 x_title="Trial",59 y_title="Duration",60 style=Style,61 min_scale=20,62 max_scale=20,63 truncate_label=50,64 range=(minimum, maximum),65 zero=minimum,66 css=[67 "file://style.css",68 "file://graph.css",69 """inline:70 .tooltip .value {71 font-size: 1em !important;72 }73 .axis text {74 font-size: 9px !important;75 }76 """77 ],78 **opts79 )80 for row in benchmarks:81 serie = [row[field] * adjustment for field in ["min", "ld15iqr", "q1", "median", "q3", "hd15iqr", "max"]]82 serie.append(row["path"])83 plot.add("{0[fullname]} - {0[rounds]} rounds".format(row), serie)84 return plot85def make_histogram(output_prefix, name, benchmarks, unit, adjustment):86 if name:87 path = "{0}-{1}.svg".format(output_prefix, slugify(name))88 title = "Speed in {0} of {1}".format(TIME_UNITS[unit], name)89 else:90 path = "{0}.svg".format(output_prefix)91 title = "Speed in {0}".format(TIME_UNITS[unit])92 output_file = py.path.local(path).ensure()93 plot = make_plot(94 benchmarks=benchmarks,95 title=title,96 adjustment=adjustment,97 )98 plot.render_to_file(str(output_file))...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-benchmark automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful