Package: litestats
LitestatsProfiling in Python has always been easy, however, analyzing the
profiler's output not so much. After the profile has been created you
can use Python'spstatsmodule but it feels quite clumsy and not
really empowering.Enter litestats! Litestats is a simple command line tool that takes the
output of the Python profiler and transforms the data into a sqlite3
database. You can now easily analyze the profiler output usingsqliteon the command line, thesqlitebrowserfor a graphical interface or
use the data base as the foundation of your very own tooling around the
analysis.How does it work?Litestats reads the dump of the profiler and creates a normalized
data base with tree tables:functions: contains each function (callers and callees) with
filename, line number and function namestatscontains the statistics (primitive/total calls,
total/cumulative time) for all functionscallsa caller-callee mappingWhile this provides an exact representation of the dump, those tables
would be cumbersome to use. So litestats additionally creates three
views resemblingpstatsprint_stats,print_callersandprint_calleesfunctionality:pstatscallerscalleesInstallLitestats hasno requirementsother than Python itself:$pipinstalllitestatsUsage$# run the profiler and dump the output$python3-mcProfile-oexample.profexample.py
$# convert dump to sqlite3 db$litestatsexample.prof
$# example.prof.sqlite createdYou can now use the sqlite3 data base to investigate the profiler dump:sqlite>select*...>frompstats...>orderbycumtimedesc...>limit20;ncallstottimettpercallcumtimectpercallfilename:lineno(function)----------  ----------  --------------------  ----------  ----------  ------------------------------------18/10.0001618.94444444444444e-060.0677970.067797~:0(<built-inmethodbuiltins.exec>)11.0e-061.0e-060.0677550.067755<string>:1(<module>)14.0e-064.0e-060.0677540.067754/usr/lib/python3.7/runpy.py:195(run_16.0e-066.0e-060.0661350.066135/usr/lib/python3.7/runpy.py:62(_run_11.1e-051.1e-050.0661130.066113/home/venthur/Documents/projects/lit16.6e-056.6e-050.0551520.055152/home/venthur/Documents/projects/lit14.1e-054.1e-050.05490.0549/home/venthur/Documents/projects/lit10.0501960.0501960.0501960.050196~:0(<method'executescript'of'sqli20/3        8.9e-05     4.45e-06              0.011064    0.003688    <frozen importlib._bootstrap>:978(_f20/3        4.8e-05     2.4e-06               0.011005    0.00366833  <frozen importlib._bootstrap>:948(_f20/3        7.5e-05     3.75e-06              0.01083     0.00361     <frozen importlib._bootstrap>:663(_l15/3        3.5e-05     2.33333333333333e-06  0.01073     0.00357666  <frozen importlib._bootstrap_externa29/5        2.5e-05     8.62068965517241e-07  0.010215    0.002043    <frozen importlib._bootstrap>:211(_c3           6.0e-06     2.0e-06               0.010087    0.00336233  ~:0(<built-in method builtins.__impo28/6        9.0e-06     3.21428571428571e-07  0.008977    0.00149616  <frozen importlib._bootstrap>:1009(_1           9.0e-06     9.0e-06               0.00841     0.00841     /home/venthur/Documents/projects/lit16          0.000138    8.625e-06             0.004802    0.00030012  <frozen importlib._bootstrap_externa1           4.5e-05     4.5e-05               0.004143    0.004143    /usr/lib/python3.7/logging/__init__.1           0.004038    0.004038              0.004038    0.004038    ~:0(<method 'commit' of 'sqlite3.Con133.3e-052.53846153846154e-060.0023680.00018215<frozenimportlib._bootstrap_externa