def make_plot(benchmarks, title, adjustment): class Style(DefaultStyle): colors = ["#000000" if row["path"] else DefaultStyle.colors[1] for row in benchmarks] font_family = 'Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace' minimum = int(min(row["min"] * adjustment for row in benchmarks)) maximum = int(max( min(row["max"], row["hd15iqr"]) * adjustment for row in benchmarks ) + 1) try: import pygaljs except ImportError: opts = {} else: opts = { "js": [ pygaljs.uri("2.0.x", "pygal-tooltips.js") ] } plot = CustomBox( box_mode='tukey', x_label_rotation=-90, x_labels=["{0[name]}".format(row) for row in benchmarks], show_legend=False, title=title, x_title="Trial", y_title="Duration", style=Style, min_scale=20, max_scale=20, truncate_label=50, range=(minimum, maximum), zero=minimum, css=[ "file://style.css", "file://graph.css", """inline: .tooltip .value { font-size: 1em !important; } .axis text { font-size: 9px !important; } """ ], **opts ) for row in benchmarks: serie = [row[field] * adjustment for field in ["min", "ld15iqr", "q1", "median", "q3", "hd15iqr", "max"]] serie.append(row["path"]) plot.add("{0[fullname]} - {0[rounds]} rounds".format(row), serie) return plot
def make_plot(bench_name, table, compare, current, annotations, sort): class Style(DefaultStyle): colors = [] font_family = 'Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace' for label, row in table: if label == current: colors.append(DefaultStyle.colors[0]) elif compare and str(compare.basename).startswith(label): colors.append(DefaultStyle.colors[2]) else: colors.append("#000000") unit, adjustment = time_unit(min( row[sort] for _, row in table )) minimum = int(min(row["min"] * adjustment for _, row in table)) maximum = int(max( min(row["max"], row["hd15iqr"]) * adjustment for _, row in table ) + 1) try: import pygaljs except ImportError: opts = {} else: opts = { "js": [ pygaljs.uri("2.0.x", "pygal-tooltips.js") ] } plot = Plot( annotations, box_mode='tukey', x_label_rotation=-90, x_labels=[label for label, _ in table], show_legend=False, title="Speed in %sseconds of %s" % (unit, bench_name), x_title="Trial", y_title="%ss" % unit, style=Style, min_scale=20, max_scale=20, range=(minimum, maximum), zero=minimum, css=[ "file://style.css", "file://graph.css", """inline: .axis.x text { text-anchor: middle !important; } .tooltip .value { font-size: 1em !important; } """ ], **opts ) for label, row in table: if label in annotations: label += "\n@%s - %s rounds" % (annotations[label]["datetime"], row["rounds"]) serie = [row[field] * adjustment for field in ["min", "ld15iqr", "q1", "median", "q3", "hd15iqr", "max"]] plot.add(label, serie) return plot
def make_plot(bench_name, table, compare, current, annotations, sort): class Style(DefaultStyle): colors = [] font_family = 'Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace' for label, row in table: if label == current: colors.append(DefaultStyle.colors[0]) elif compare and str(compare.basename).startswith(label): colors.append(DefaultStyle.colors[2]) else: colors.append("#000000") unit, adjustment = time_unit(min(row[sort] for _, row in table)) minimum = int(min(row["min"] * adjustment for _, row in table)) maximum = int( max(min(row["max"], row["hd15iqr"]) * adjustment for _, row in table) + 1) try: import pygaljs except ImportError: opts = {} else: opts = {"js": [pygaljs.uri("2.0.x", "pygal-tooltips.js")]} plot = Plot(annotations, box_mode='tukey', x_label_rotation=-90, x_labels=[label for label, _ in table], show_legend=False, title="Speed in %sseconds of %s" % (unit, bench_name), x_title="Trial", y_title="%ss" % unit, style=Style, min_scale=20, max_scale=20, range=(minimum, maximum), zero=minimum, css=[ "file://style.css", "file://graph.css", """inline: .axis.x text { text-anchor: middle !important; } .tooltip .value { font-size: 1em !important; } """ ], **opts) for label, row in table: if label in annotations: label += "\n@%s - %s rounds" % (annotations[label]["datetime"], row["rounds"]) serie = [ row[field] * adjustment for field in ["min", "ld15iqr", "q1", "median", "q3", "hd15iqr", "max"] ] plot.add(label, serie) return plot