module pycode.profiling
¶
Functions¶
function |
truncated documentation |
---|---|
Converts class Stats into something readable for … |
|
Profiles the execution of a function. |
Documentation¶
Profiling helpers
-
pyquickhelper.pycode.profiling.
_process_pstats
(ps, clean_text)[source]¶ Converts class Stats into something readable for a dataframe.
-
pyquickhelper.pycode.profiling.
profile
(fct, sort='cumulative', rootrem=None, as_df=False, pyinst_format=None, **kwargs)[source]¶ Profiles the execution of a function.
- Parameters
fct – function to profile
sort – see sort_stats
rootrem – root to remove in filenames
as_df – return the results as a dataframe and not text
pyinst_format – format for pyinstrument, if not empty, the function uses this module or raises an exception if not installed, the options are text, textu (text with colors), json, html
kwargs – additional parameters used to create the profiler
- Returns
raw results, statistics text dump (or dataframe is as_df is True)
import matplotlib.pyplot as plt from pyquickhelper.pycode.profiling import profile from pyquickhelper.texthelper import compare_module_version def fctm(): return compare_module_version('0.20.4', '0.22.dev0') pr, df = profile(lambda: [fctm() for i in range(0, 1000)], as_df=True) ax = df[['namefct', 'cum_tall']].head(n=15).set_index( 'namefct').plot(kind='bar', figsize=(8, 3), rot=30) ax.set_title("example of a graph") for la in ax.get_xticklabels(): la.set_horizontalalignment('right'); plt.show()