=========
Pyrofiler
=========
.. image:: https://img.shields.io/pypi/v/pyrofiler.svg
:target: https://pypi.python.org/pypi/pyrofiler
.. image:: https://img.shields.io/travis/DaniloZZZ/pyrofiler.svg
:target: https://travis-ci.com/DaniloZZZ/pyrofiler
.. image:: https://readthedocs.org/projects/pyrofiler/badge/?version=latest
:target: https://pyrofiler.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Toolset for granular memory and cpu live profiling
Quick start
-----------
Contextmanager that measures time of execution
.. code-block:: python
# examples/simple_profile.py
import pyrofiler
import time
with pyrofiler.timing('Time elapsed'):
time.sleep(1)
.. code-block:: console
$ python simple_profile.py
Time elapsed : 1.001563310623169
Decorators for profiling functions
.. code-block:: python
# examples/simple_profile_cpu.py
import pyrofiler
@pyrofiler.cpu_util(description='Cpu usage')
@pyrofiler.timed('Time elapsed')
def sum_series(x, N):
return sum([x**i/i for i in range(1, N)])
sum_series(.3, 1000_000)
.. code-block:: console
$ python simple_profile_cpu.py
Time elapsed : 0.13478374481201172
Cpu usage : 29.4
Aggregate the results in common context:
.. code-block:: python
# examples/profile_with_context.py
from pyrofiler import Profiler
import time
prof = Profiler()
with prof.timing('Time 1'):
time.sleep(1)
with prof.timing('Time 2'):
time.sleep(1.5)
print('Profiling data recorded:')
print(prof.data)
.. code-block:: console
$ python profile_with_context.py
Time 1 : 1.0011215209960938
Time 2 : 1.5020403861999512
Profiling data recorded:
{'Time 1': 1.0011215209960938, 'Time 2': 1.5020403861999512}
You can use other actions, for example appending results to some list in data.
Check the `documentation <https://pyrofiler.readthedocs.io/en/latest/usage.html>`_ for more use cases
Design
------
There are following types of objects in pyrofiler:
#. `Measures`, which are run as a context manager
#. `Decorators`, that are based on `measures`
#. `Profiler` class that uses `decorators` to aggregate data
Callbacks
=========
The `decorators` have an optional argument ``callback``,
to which you can pass a function that will handle the data.
The function will be passed profiling results as a first argument,
as well as any other arguments that you provided to original `decorator`.
Here, a custom ``spice`` argument is provided
.. code-block:: python
def print_spicy_time(time, spice):
print(f'Spice {spice} took {time} seconds')
@pyrofiler.timed(spice='spicy', callback=print_spicy_time)
def spicy_sleep():
time.sleep(10)
Similar products
----------------
- Syrpy https://github.com/jeetsukumaran/Syrupy
- Scalene https://github.com/emeryberger/scalene
- ... and lots of `others <https://github.com/matuskosut/python-perfres/>`_
Problems
--------
Either you have a cli tool that profiles memory and cpu, but **no code api for granular data**
or you have stuff like decorators and **no memory profiling**
Having a live dashboard would help also, use https://github.com/libvis for that
Features
--------
* TODO
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.1.0 (2020-03-04)
------------------
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/DaniloZZZ/pyrofiler",
"name": "pyrofiler",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "pyrofiler",
"author": "Dan Lykov",
"author_email": "lkv97dn@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/af/e8/d6704f96bc2d2de34581dc121d4f0e83a3c8772c80c0079938f7416b10dd/pyrofiler-0.1.11.tar.gz",
"platform": null,
"description": "=========\nPyrofiler\n=========\n\n\n.. image:: https://img.shields.io/pypi/v/pyrofiler.svg\n :target: https://pypi.python.org/pypi/pyrofiler\n\n.. image:: https://img.shields.io/travis/DaniloZZZ/pyrofiler.svg\n :target: https://travis-ci.com/DaniloZZZ/pyrofiler\n\n.. image:: https://readthedocs.org/projects/pyrofiler/badge/?version=latest\n :target: https://pyrofiler.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\n\nToolset for granular memory and cpu live profiling\n\n\nQuick start\n-----------\n\nContextmanager that measures time of execution\n\n.. code-block:: python\n\n # examples/simple_profile.py\n import pyrofiler\n import time\n\n with pyrofiler.timing('Time elapsed'):\n time.sleep(1)\n\n.. code-block:: console\n\n $ python simple_profile.py\n Time elapsed : 1.001563310623169\n\n\nDecorators for profiling functions\n\n.. code-block:: python\n\n # examples/simple_profile_cpu.py\n import pyrofiler\n\n @pyrofiler.cpu_util(description='Cpu usage')\n @pyrofiler.timed('Time elapsed')\n def sum_series(x, N):\n return sum([x**i/i for i in range(1, N)])\n\n sum_series(.3, 1000_000)\n\n.. code-block:: console\n\n $ python simple_profile_cpu.py\n Time elapsed : 0.13478374481201172\n Cpu usage : 29.4\n\nAggregate the results in common context:\n\n.. code-block:: python\n\n # examples/profile_with_context.py\n from pyrofiler import Profiler\n import time\n\n prof = Profiler()\n\n with prof.timing('Time 1'):\n time.sleep(1)\n\n with prof.timing('Time 2'):\n time.sleep(1.5)\n\n print('Profiling data recorded:')\n print(prof.data)\n\n.. code-block:: console\n\n $ python profile_with_context.py \n Time 1 : 1.0011215209960938\n Time 2 : 1.5020403861999512\n Profiling data recorded:\n {'Time 1': 1.0011215209960938, 'Time 2': 1.5020403861999512}\n\nYou can use other actions, for example appending results to some list in data.\nCheck the `documentation <https://pyrofiler.readthedocs.io/en/latest/usage.html>`_ for more use cases\n\n\nDesign\n------\n\nThere are following types of objects in pyrofiler:\n\n#. `Measures`, which are run as a context manager\n\n#. `Decorators`, that are based on `measures`\n\n#. `Profiler` class that uses `decorators` to aggregate data\n\n\nCallbacks\n=========\n\nThe `decorators` have an optional argument ``callback``,\nto which you can pass a function that will handle the data.\nThe function will be passed profiling results as a first argument,\nas well as any other arguments that you provided to original `decorator`.\n\nHere, a custom ``spice`` argument is provided\n\n.. code-block:: python\n\n def print_spicy_time(time, spice):\n print(f'Spice {spice} took {time} seconds')\n\n @pyrofiler.timed(spice='spicy', callback=print_spicy_time)\n def spicy_sleep():\n time.sleep(10)\n\nSimilar products\n----------------\n\n- Syrpy https://github.com/jeetsukumaran/Syrupy \n- Scalene https://github.com/emeryberger/scalene\n- ... and lots of `others <https://github.com/matuskosut/python-perfres/>`_\n\nProblems\n--------\nEither you have a cli tool that profiles memory and cpu, but **no code api for granular data** \n\nor you have stuff like decorators and **no memory profiling**\n\nHaving a live dashboard would help also, use https://github.com/libvis for that\n\n\nFeatures\n--------\n\n* TODO\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.1.0 (2020-03-04)\n------------------\n\n* First release on PyPI.\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "Toolset for granular and live profiling",
"version": "0.1.11",
"split_keywords": [
"pyrofiler"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02dfcdf7eadbcd54a5e8ff98879fd8b6d282d079150608f3d78cbe8b2a9cc40d",
"md5": "94f3da0ef2ad88fb3c400a9927419a0e",
"sha256": "6204be45d04ac014ddb23c08d7d78a48158fcc7b4aef8b20c68579a2ee19018f"
},
"downloads": -1,
"filename": "pyrofiler-0.1.11-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "94f3da0ef2ad88fb3c400a9927419a0e",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.5",
"size": 10401,
"upload_time": "2023-01-26T20:48:57",
"upload_time_iso_8601": "2023-01-26T20:48:57.490082Z",
"url": "https://files.pythonhosted.org/packages/02/df/cdf7eadbcd54a5e8ff98879fd8b6d282d079150608f3d78cbe8b2a9cc40d/pyrofiler-0.1.11-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "afe8d6704f96bc2d2de34581dc121d4f0e83a3c8772c80c0079938f7416b10dd",
"md5": "7d2eff169945c2d6bb7652a3b9a95e5c",
"sha256": "7134c3e3c4f1b70e460c8c2ee7ef48bf245efb662c72a5d818881b0eb6de468c"
},
"downloads": -1,
"filename": "pyrofiler-0.1.11.tar.gz",
"has_sig": false,
"md5_digest": "7d2eff169945c2d6bb7652a3b9a95e5c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 22054,
"upload_time": "2023-01-26T20:48:59",
"upload_time_iso_8601": "2023-01-26T20:48:59.342547Z",
"url": "https://files.pythonhosted.org/packages/af/e8/d6704f96bc2d2de34581dc121d4f0e83a3c8772c80c0079938f7416b10dd/pyrofiler-0.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-26 20:48:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "DaniloZZZ",
"github_project": "pyrofiler",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "psutil",
"specs": []
}
],
"tox": true,
"lcname": "pyrofiler"
}