Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shuttle1987/pythonprofilingexample
Example of profiling python code
https://github.com/shuttle1987/pythonprofilingexample
Last synced: 14 days ago
JSON representation
Example of profiling python code
- Host: GitHub
- URL: https://github.com/shuttle1987/pythonprofilingexample
- Owner: shuttle1987
- License: agpl-3.0
- Created: 2020-02-17T22:13:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T23:08:22.000Z (almost 5 years ago)
- Last Synced: 2024-11-17T13:49:54.465Z (3 months ago)
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PythonProfilingExample
There's a couple of example snippets of sorting code in `sorting.py` including everyone's favorite bogosort for extra slow (factorial complexity) sorting performance.
## cProfile
You can get a sense of the runtime of Python code with the standard library module cProfile
Try with this:
```bash
python3 -m cProfile slow.py
```Compare with:
```bash
python3 -m cProfile fast.py
```## Snakeviz
Snakeviz will allow you to see the results of a profiling dump in a nice rendered output.
Do the usual environment stuff then install with:
```bash
pip install snakeviz
```First create profile output using:
```bash
python3 -m cProfile -o fast.prof fast.py
``````bash
python3 -m cProfile -o slow.prof slow.py
```Then see the nice visualizaton in your browser using:
```bash
snakeviz slow.prof
```