{ "info": { "author": "Bastian Venthur", "author_email": "mail@venthur.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3" ], "description": "# Litestats\n\nProfiling in Python has always been easy, however, analyzing the\nprofiler's output not so much. After the profile has been created you\ncan use Python's `pstats` module but it feels quite clumsy and not\nreally empowering.\n\nEnter litestats! Litestats is a simple command line tool that takes the\noutput of the Python profiler and transforms the data into a sqlite3\ndatabase. You can now easily analyze the profiler output using `sqlite`\non the command line, the `sqlitebrowser` for a graphical interface or\nuse the data base as the foundation of your very own tooling around the\nanalysis.\n\n## How does it work?\n\nLitestats reads the dump of the profiler and creates a normalized\ndata base with tree tables:\n\n * `functions`: contains each function (callers and callees) with\n filename, line number and function name\n * `stats` contains the statistics (primitive/total calls,\n total/cumulative time) for all functions\n * `calls` a caller-callee mapping\n\nWhile this provides an exact representation of the dump, those tables\nwould be cumbersome to use. So litestats additionally creates three\nviews resembling `pstats` `print_stats`, `print_callers` and\n`print_callees` functionality:\n\n * `pstats`\n * `callers`\n * `callees`\n\n## Install\n\nLitestats has **no requirements** other than Python itself:\n\n```bash\n$ pip install litestats\n```\n\n\n## Usage\n\n```bash\n$ # run the profiler and dump the output\n$ python3 -m cProfile -o example.prof example.py\n$ # convert dump to sqlite3 db\n$ litestats example.prof\n$ # example.prof.sqlite created\n```\n\nYou can now use the sqlite3 data base to investigate the profiler dump:\n\n```sql\nsqlite> select *\n ...> from pstats\n ...> order by cumtime desc\n ...> limit 20;\n\nncalls tottime ttpercall cumtime ctpercall filename:lineno(function)\n---------- ---------- -------------------- ---------- ---------- ------------------------------------\n18/1 0.000161 8.94444444444444e-06 0.067797 0.067797 ~:0()\n1 1.0e-06 1.0e-06 0.067755 0.067755 :1()\n1 4.0e-06 4.0e-06 0.067754 0.067754 /usr/lib/python3.7/runpy.py:195(run_\n1 6.0e-06 6.0e-06 0.066135 0.066135 /usr/lib/python3.7/runpy.py:62(_run_\n1 1.1e-05 1.1e-05 0.066113 0.066113 /home/venthur/Documents/projects/lit\n1 6.6e-05 6.6e-05 0.055152 0.055152 /home/venthur/Documents/projects/lit\n1 4.1e-05 4.1e-05 0.0549 0.0549 /home/venthur/Documents/projects/lit\n1 0.050196 0.050196 0.050196 0.050196 ~:0(:978(_f\n20/3 4.8e-05 2.4e-06 0.011005 0.00366833 :948(_f\n20/3 7.5e-05 3.75e-06 0.01083 0.00361 :663(_l\n15/3 3.5e-05 2.33333333333333e-06 0.01073 0.00357666 :211(_c\n3 6.0e-06 2.0e-06 0.010087 0.00336233 ~:0(:1009(_\n1 9.0e-06 9.0e-06 0.00841 0.00841 /home/venthur/Documents/projects/lit\n16 0.000138 8.625e-06 0.004802 0.00030012