profiling-helpers


Nameprofiling-helpers JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/NobisIndustries/python-profiling-helpers
SummaryA small utility library that wraps cProfile and makes it easy to debug performance problems in your Python code.
upload_time2023-07-18 06:54:17
maintainer
docs_urlNone
authorFabian Nobis
requires_python>=3.7
licenseMIT
keywords cprofile profiling performance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Profiling Helpers

A small python package that wraps Python's own `cProfile` library to make it more user friendly.


When developing Python programs, you'll sometimes have functions that take a long time to execute and
you are really not sure why. Profiling helps to find and analyze these bottlenecks and guides you
into fixing performance problems. Uses [snakeviz](https://jiffyclub.github.io/snakeviz/) for interactive visualizations.

Install it with `pip install profiling-helpers`.
Visualize profile files with `snakeviz profile_xyz.prof`.

There are two decorators, `time_it` and `profile_it`. Use them anywhere in your code, like this:

```python
from profiling_helpers import time_it, profile_it
from time import sleep

@time_it
def my_slow_function(x):
    sleep(10)
    return x

my_slow_function(42)  # Prints: Function "my_slow_function" took 10.01061 s to run
```


```python
@profile_it("my/profile/save/dir", open_visualization=True)
def my_slow_function(x):
    sleep(10)
    return x

my_slow_function(42)  # Opens snakeviz after this function is completed
```

Profiles are normally saved on the local file system. If you have other save targets, you can
either use included FileSavers (currently only for AWS S3) or implement your own one by inheriting
from the `BaseFileSaver` class. Here is a variant with S3:

```python
from profiling_helpers import profile_it, S3FileSaver

@profile_it(S3FileSaver("s3://my-bucket/my/path/to/profiles/", kms_key_id="..."))
def my_slow_function(x):
    sleep(10)
    return x

my_slow_function(42)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NobisIndustries/python-profiling-helpers",
    "name": "profiling-helpers",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "cProfile,profiling,performance",
    "author": "Fabian Nobis",
    "author_email": "fabiannobis@gmx.de",
    "download_url": "https://files.pythonhosted.org/packages/d4/1c/9c14f1b52cb252ce6754fb687b225dcce0935bad918ac7a491f9568cbbf0/profiling-helpers-0.2.0.tar.gz",
    "platform": "any",
    "description": "# Profiling Helpers\n\nA small python package that wraps Python's own `cProfile` library to make it more user friendly.\n\n\nWhen developing Python programs, you'll sometimes have functions that take a long time to execute and\nyou are really not sure why. Profiling helps to find and analyze these bottlenecks and guides you\ninto fixing performance problems. Uses [snakeviz](https://jiffyclub.github.io/snakeviz/) for interactive visualizations.\n\nInstall it with `pip install profiling-helpers`.\nVisualize profile files with `snakeviz profile_xyz.prof`.\n\nThere are two decorators, `time_it` and `profile_it`. Use them anywhere in your code, like this:\n\n```python\nfrom profiling_helpers import time_it, profile_it\nfrom time import sleep\n\n@time_it\ndef my_slow_function(x):\n    sleep(10)\n    return x\n\nmy_slow_function(42)  # Prints: Function \"my_slow_function\" took 10.01061 s to run\n```\n\n\n```python\n@profile_it(\"my/profile/save/dir\", open_visualization=True)\ndef my_slow_function(x):\n    sleep(10)\n    return x\n\nmy_slow_function(42)  # Opens snakeviz after this function is completed\n```\n\nProfiles are normally saved on the local file system. If you have other save targets, you can\neither use included FileSavers (currently only for AWS S3) or implement your own one by inheriting\nfrom the `BaseFileSaver` class. Here is a variant with S3:\n\n```python\nfrom profiling_helpers import profile_it, S3FileSaver\n\n@profile_it(S3FileSaver(\"s3://my-bucket/my/path/to/profiles/\", kms_key_id=\"...\"))\ndef my_slow_function(x):\n    sleep(10)\n    return x\n\nmy_slow_function(42)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A small utility library that wraps cProfile and makes it easy to debug performance problems in your Python code.",
    "version": "0.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/NobisIndustries/python-profiling-helpers/issues",
        "Homepage": "https://github.com/NobisIndustries/python-profiling-helpers"
    },
    "split_keywords": [
        "cprofile",
        "profiling",
        "performance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "acb27b2d9ff7ba8bf93d99a6fe17ac0cb8e8841f6e423989d5e9188934bd1ef8",
                "md5": "84d59e33987f1ddd1decdfff0cebc75f",
                "sha256": "05a21a978a2c698e3c01aa4ff1329b64c5537a9308e670e4efe04ad516ebcd73"
            },
            "downloads": -1,
            "filename": "profiling_helpers-0.2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "84d59e33987f1ddd1decdfff0cebc75f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 6266,
            "upload_time": "2023-07-18T06:54:15",
            "upload_time_iso_8601": "2023-07-18T06:54:15.699896Z",
            "url": "https://files.pythonhosted.org/packages/ac/b2/7b2d9ff7ba8bf93d99a6fe17ac0cb8e8841f6e423989d5e9188934bd1ef8/profiling_helpers-0.2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d41c9c14f1b52cb252ce6754fb687b225dcce0935bad918ac7a491f9568cbbf0",
                "md5": "509980852ee375bd92eb563e32b7a29d",
                "sha256": "fcc86e80d7ca9f3fbdd8f208cd69758f34a385809b18d91413919a192647b348"
            },
            "downloads": -1,
            "filename": "profiling-helpers-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "509980852ee375bd92eb563e32b7a29d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5656,
            "upload_time": "2023-07-18T06:54:17",
            "upload_time_iso_8601": "2023-07-18T06:54:17.196285Z",
            "url": "https://files.pythonhosted.org/packages/d4/1c/9c14f1b52cb252ce6754fb687b225dcce0935bad918ac7a491f9568cbbf0/profiling-helpers-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-18 06:54:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NobisIndustries",
    "github_project": "python-profiling-helpers",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "profiling-helpers"
}
        
Elapsed time: 1.69469s