Visualize the results of profiling in a bokeh plot. If multiple profilers are passed in, the plots are stacked vertically. Parameters ---------- profilers : profiler or list Profiler or list of profilers. filename : string, optional Name of the plot output file.
(
profilers, filename="profile.html", show=True, save=None, mode=None, **kwargs
)
| 65 | |
| 66 | |
| 67 | def visualize( |
| 68 | profilers, filename="profile.html", show=True, save=None, mode=None, **kwargs |
| 69 | ): |
| 70 | """Visualize the results of profiling in a bokeh plot. |
| 71 | |
| 72 | If multiple profilers are passed in, the plots are stacked vertically. |
| 73 | |
| 74 | Parameters |
| 75 | ---------- |
| 76 | profilers : profiler or list |
| 77 | Profiler or list of profilers. |
| 78 | filename : string, optional |
| 79 | Name of the plot output file. |
| 80 | show : boolean, optional |
| 81 | If True (default), the plot is opened in a browser. |
| 82 | save : boolean, optional |
| 83 | If True (default when not in notebook), the plot is saved to disk. |
| 84 | mode : str, optional |
| 85 | Mode passed to bokeh.output_file() |
| 86 | **kwargs |
| 87 | Other keyword arguments, passed to bokeh.figure. These will override |
| 88 | all defaults set by visualize. |
| 89 | |
| 90 | Returns |
| 91 | ------- |
| 92 | The completed bokeh plot object. |
| 93 | """ |
| 94 | bp = import_required("bokeh.plotting", _BOKEH_MISSING_MSG) |
| 95 | from bokeh.io import state |
| 96 | |
| 97 | if "file_path" in kwargs: |
| 98 | warnings.warn( |
| 99 | "The file_path keyword argument is deprecated " |
| 100 | "and will be removed in a future release. " |
| 101 | "Please use filename instead.", |
| 102 | category=FutureWarning, |
| 103 | stacklevel=2, |
| 104 | ) |
| 105 | filename = kwargs.pop("file_path") |
| 106 | |
| 107 | if save is None: |
| 108 | save = not state.curstate().notebook |
| 109 | |
| 110 | if not isinstance(profilers, list): |
| 111 | profilers = [profilers] |
| 112 | figs = [prof._plot(**kwargs) for prof in profilers] |
| 113 | # Stack the plots |
| 114 | if len(figs) == 1: |
| 115 | p = figs[0] |
| 116 | else: |
| 117 | top = figs[0] |
| 118 | for f in figs[1:]: |
| 119 | f.x_range = top.x_range |
| 120 | f.title = None |
| 121 | f.min_border_top = 20 |
| 122 | f.height -= 30 |
| 123 | for f in figs[:-1]: |
| 124 | f.xaxis.axis_label = None |
searching dependent graphs…