pyquickbench.plot_benchmark#
- plot_benchmark(all_vals, all_args, all_funs=None, *, all_fun_names=None, all_out_names=None, plot_intent=None, plot_type=None, mode='timings', setup=None, all_xvalues=None, color_list=['tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan', (0, 0, 1), (0, 0.5, 0), (1, 0, 0), (0.75, 0, 0.75), (0, 0, 0)], linestyle_list=['solid', 'dotted', 'dashed', 'dashdot', (0, (1, 10)), (0, (1, 1)), (0, (1, 1)), (5, (10, 3)), (0, (5, 10)), (0, (5, 5)), (0, (5, 1)), (0, (3, 10, 1, 10)), (0, (3, 5, 1, 5)), (0, (3, 1, 1, 1)), (0, (3, 5, 1, 5, 1, 5)), (0, (3, 10, 1, 10, 1, 10)), (0, (3, 1, 1, 1, 1, 1))], pointstyle_list=[None, '.', 'o', 'v', '^', '<', '>', '1', '2', '3', '4', '8', 's', 'p', 'P', '*', 'h', 'H', '+', 'x', 'X', 'D', 'd'], alpha=1.0, violin_width_mul=0.5, violin_showmeans=False, violin_showextrema=True, violin_showmedians=False, violin_show_observations=False, violin_side='both', single_values_idx=None, single_values_val=None, logx_plot=None, logy_plot=None, plot_xlim=None, plot_ylim=None, show=False, return_empty_plot=False, fig=None, ax=None, dpi=150, pxl_per_plot_x=1600, pxl_per_plot_y=800, sharex=True, sharey=False, title=None, xlabel=None, ylabel=None, plot_legend=None, ProductLegend=False, legend_location='upper left', plot_grid=True, relative_to_idx=None, relative_to_val=None, transform=None, clip_vals=False, stop_after_first_clip=False, filename=None)[source]#
Plots benchmarks results
- Parameters:
all_vals (
numpy.ndarray
) – Benchmark results as returned bypyquickbench.run_benchmark()
.all_args (
dict
|typing.Iterable
) – Describes the arguments given to the functions in the benchmark.all_funs (
dict
[str
, iterable] |typing.Iterable
[str
] |None
, optional) –Benchmarked functions, by default
None
.Only the
function.__name__
attribute is used here.all_fun_names (
typing.Iterable
[str
] | None, optional) –Names of the benchmarked functions, by default
None
.In case the functions
function.__name__
attribute is missing or uninformative.all_out_names (
typing.Iterable
[str
] | None, optional) – Names of the outputs of the functions ifmode="vector_output"
, by defaultNone
.plot_intent (
typing.Iterable
[str
] | None, optional) –Describes how to handle the axes of the benchmark results array
all_vals
.See Multidimensional benchmarks for usage examples.
By default
None
.plot_type (
typing.Iterable
[str
] | None, optional) –Any value that is not
None
overrides the default plot_type.Possible values :
"bar"
,"curve"
,"violin"
.By default
None
.mode (
str
, optional) –Benchmark mode, i.e. target of the benchmark.
See Plotting scalar values for usage example.
Possible values:
"timings"
or"scalar_output"
. By default"timings"
.setup (callable, optional) –
Function that prepares the inputs for the functions to be benchmarked.
See Preparing inputs for usage example.
Only used if
all_out_names
was not provided andmode="vector_output"
By default
lambda n: {pyquickbench.default_ax_name: n}
.all_xvalues (
numpy.ndarray
|None
, optional) –Values to be plotted on the x-axis if those differ from argument values.
See Plotting scalar values for usage example.
By default
None
.color_list (
list
[str
], optional) – List of colors for plotted curves, by defaultdefault_color_list
.linestyle_list (
list
[str
], optional) – List of linestyles for plotted curves, by defaultdefault_linestyle_list
.pointstyle_list (
list
[str
], optional) – List of point markers for plotted curves, by defaultdefault_pointstyle_list
.alpha (
float
, optional) –Alpha value for transparency of curves in plot.
By default,
1.
meaning curves are fully opaque.violin_width_mul (
float
, optional) –Factor on violin plot width. Decrease this value for thinner plot, and increase for fatter ones.
By default,
0.5
.violin_showmeans (
bool
, optional) – Whether to show mean values in violin plots, by defaultFalse
.violin_showextrema (
bool
, optional) – Whether to show min/max values in violin plots, by defaultTrue
.violin_showmedians (
bool
, optional) – Whether to show median values in violin plots, by defaultFalse
.violin_show_observations (
bool
, optional) – Whether to show individual observations in violin plot, by defaultFalse
.violin_side (
str
|None
, optional) –Side of the Kernel Density Estimation reconstruction in violin plots. Possible values:
"both"
,"left"
,"right"
,None
.By default
"both"
.single_values_idx (
dict
|None
, optional) –Indices of benchmarked values to be fixed by a
plot_intent
of"single_value"
.See Multidimensional benchmarks for usage example.
By default
None
.single_values_val (
dict
|None
, optional) –Values of benchmark to be fixed by a
plot_intent
of"single_value"
.See Multidimensional benchmarks for usage example.
By default
None
.logx_plot (
bool
|None
, optional) – How to override log scaling on the x-axis of the plots, by defaultNone
.logy_plot (
bool
|None
, optional) – How to override log scaling on the y-axis of the plots, by defaultNone
.plot_xlim (
tuple
|None
, optional) – How to override limits on the x-axis of the plots, by defaultNone
.plot_ylim (
tuple
|None
, optional) – How to override limits on the y-axis of the plots, by defaultNone
.show (
bool
, optional) – Whether to issue a call tomatplotlib.pyplot.show()
instead of returning a(fig, ax)
tuple, by defaultFalse
.return_empty_plot (
bool
, optional) – Whether to prematurely return an empty(fig, ax)
tuple. Useful to create an empty plot and reuse it, see Multidimensional benchmarks for instance. By defautFalse
.fig (
matplotlib.figure.Figure
|None
, optional) –User provided
matplotlib.figure.Figure
object. IfNone
, a new one is generated.Typically, this argument is the result of a former call to
pyquickbench.plot_benchmark()
, potentially using argumentreturn_empty_plot = True
.By default
None
.ax (
numpy.ndarray
[matplotlib.axes.Axes
] |None
, optional) –User provided array of
matplotlib.axes.Axes
objects as returned bymatplotlib.pyplot.subplots()
.Typically, this argument is the result of a former call to
pyquickbench.plot_benchmark()
, potentially using argumentreturn_empty_plot = True
.By default
None
.dpi (
int
, optional) – Output image resolution, by default150
.pxl_per_plot_x (
int
, optional) – Output plot width, by default1600
.pxl_per_plot_y (
int
, optional) – Output plot height, by default800
.sharex (
bool
, optional) – Whether to share plot x-axis, by defaultTrue
.sharey (
bool
, optional) – Whether to share plot y-axis, by defaultFalse
.title (
str
|None
, optional) – Image title, by defaultNone
.xlabel (
str
|None
, optional) – Override argument value as a default for plot x label, by defaultNone
.ylabel (
str
|None
, optional) – Override default for plot y label, by defaultNone
.plot_legend (
bool
|dict
|None
, optional) – Whether to record each axis of the benchmark in a legend, by defaultNone
.legend_location (
str
, optional) – Location of plot legend as given tomatplotlib.axes.Axes.legend()
, by default"upper left"
.plot_grid (
bool
, optional) – Whether to plot a background grid to each plot, by defaultTrue
.ProductLegend (
bool
, optional) –Whether to detail every curve in the legend, or aggregate benchmark axes, leading to more concise legends.
By default
False
.relative_to_idx (
dict
|None
, optional) –Indices of benchmarked values against which curves will be plotted.
See Plotting transformed values for usage example.
By default
None
.relative_to_val (
dict
| None, optional) –Values of benchmark against which curves will be plotted.
See Plotting transformed values for usage example.
By default
None
.transform (
str
|None
, optional) –Data transformation before plotting, by default
None
.See Plotting transformed values for usage example.
clip_vals (
bool
, optional) –Whether to clip values that are out of bounds. Requires the argument
plot_ylim
tu be set explicitely. By defaultNone
.See Plotting transformed values for usage example.
stop_after_first_clip (
bool
, optional) – Whether to stop plotting after the first clipped value ifclip_vals == True
, by defaultFalse
.filename (
str
|None
, optional) –If not
None
, saves resulting figure infilename
.By default
None
.
- Returns:
Matplotlib figure and axes with the benchmark results, only if
show == False
.- Return type:
tuple
[matplotlib.figure.Figure
,numpy.ndarray
[matplotlib.axes.Axes
]] |None