get-profile


Nameget-profile JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryQuickly profile your code with a single line of code.
upload_time2023-01-17 23:58:15
maintainer
docs_urlNone
authorSonny George
requires_python
license
keywords python profiling profile runtime decorator cprofile
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# get-profile

A simple library to inject the most profiling bang-for-buck into a single line of code (decorator).

I.E.

```python
import time

from get_profile import get_profile


def your_function_a():
    time.sleep(1)

def your_function_b():
    time.sleep(2)


@get_profile
def your_program():
    your_function_a()
    your_function_b()


if __name__ == '__main__':
    your_program()
```
Would print something like this after your program has run:

```
Profiling results for "your_program":

===============================================================================================================================
| func                      | ncalls | tottime -r | percall -r | tottime | percall | callees                                  |
===============================================================================================================================
| CALLABLE: your_program    | 1      | 3.0073     | 3.0073     | 0.0003  | 0.0     | CALLABLE: your_function_a                |
| LINENO: 13                |        |            |            |         |         | LINENO: 6                                |
| FILE: /Users/sonnygeorge/ |        |            |            |         |         | FILE: /Users/sonnygeorge/get-profile/exa |
| get-profile/example.py    |        |            |            |         |         | mple.py                                  |
|                           |        |            |            |         |         |                                          |
|                           |        |            |            |         |         | CALLABLE: your_function_b                |
|                           |        |            |            |         |         | LINENO: 9                                |
|                           |        |            |            |         |         | FILE: /Users/sonnygeorge/get-profile/exa |
|                           |        |            |            |         |         | mple.py                                  |
-------------------------------------------------------------------------------------------------------------------------------
| <built-in method time.sle | 2      | 3.007      | 1.5035     | 3.007   | 2.0     |                                          |
| ep>                       |        |            |            |         |         |                                          |
-------------------------------------------------------------------------------------------------------------------------------
| CALLABLE: your_function_b | 1      | 2.002      | 2.002      | 0.0     | 0.0     | <built-in method time.sleep>             |
| LINENO: 9                 |        |            |            |         |         |                                          |
| FILE: /Users/sonnygeorge/ |        |            |            |         |         |                                          |
| get-profile/example.py    |        |            |            |         |         |                                          |
-------------------------------------------------------------------------------------------------------------------------------
| CALLABLE: your_function_a | 1      | 1.005      | 1.005      | 0.0     | 0.0     | <built-in method time.sleep>             |
| LINENO: 6                 |        |            |            |         |         |                                          |
| FILE: /Users/sonnygeorge/ |        |            |            |         |         |                                          |
| get-profile/example.py    |        |            |            |         |         |                                          |
-------------------------------------------------------------------------------------------------------------------------------
```


Installation
------------
``get-profile`` can be installed with ``pip``:

    $ pip install get-profile


Decorator Parameters
--------------------

Release 0.0.2 supports the following parameters for the get_profile decorator:

```python
get_profile(

# topn limits the table to only the top n rows
top_n: int = 10,

# only_my_functions = True will filter out functions whose 
# "func" field contains the regex pattern: 
# r"/python[0-9]+\.[0-9]+/|<.*>",
# (a hacky way to limit the output to just your own functions)
only_my_functions: bool = False,  

# sort_by is the column you would like to sort by (descending)
sort_by: str = "tottime -r",

# min_col is the column you would like to filter by (min_val)
min_col: str = "tottime -r",

# min_val is the minimum value for the min_col
min_val: float = 0.005,

# output_width is the width in chars of the output table
output_width: int = 150,

# toggles whether or not the "calees" column is printed
callees: bool = True,

)
```



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "get-profile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,profiling,profile,runtime,decorator,cprofile",
    "author": "Sonny George",
    "author_email": "<sonnygeorge5@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/0c/8b/e931e6f4e367731f818ef155055f0ba5a4d46d25c42fd5e390dbc000ec77/get-profile-0.0.2.tar.gz",
    "platform": null,
    "description": "\n# get-profile\n\nA simple library to inject the most profiling bang-for-buck into a single line of code (decorator).\n\nI.E.\n\n```python\nimport time\n\nfrom get_profile import get_profile\n\n\ndef your_function_a():\n    time.sleep(1)\n\ndef your_function_b():\n    time.sleep(2)\n\n\n@get_profile\ndef your_program():\n    your_function_a()\n    your_function_b()\n\n\nif __name__ == '__main__':\n    your_program()\n```\nWould print something like this after your program has run:\n\n```\nProfiling results for \"your_program\":\n\n===============================================================================================================================\n| func                      | ncalls | tottime -r | percall -r | tottime | percall | callees                                  |\n===============================================================================================================================\n| CALLABLE: your_program    | 1      | 3.0073     | 3.0073     | 0.0003  | 0.0     | CALLABLE: your_function_a                |\n| LINENO: 13                |        |            |            |         |         | LINENO: 6                                |\n| FILE: /Users/sonnygeorge/ |        |            |            |         |         | FILE: /Users/sonnygeorge/get-profile/exa |\n| get-profile/example.py    |        |            |            |         |         | mple.py                                  |\n|                           |        |            |            |         |         |                                          |\n|                           |        |            |            |         |         | CALLABLE: your_function_b                |\n|                           |        |            |            |         |         | LINENO: 9                                |\n|                           |        |            |            |         |         | FILE: /Users/sonnygeorge/get-profile/exa |\n|                           |        |            |            |         |         | mple.py                                  |\n-------------------------------------------------------------------------------------------------------------------------------\n| <built-in method time.sle | 2      | 3.007      | 1.5035     | 3.007   | 2.0     |                                          |\n| ep>                       |        |            |            |         |         |                                          |\n-------------------------------------------------------------------------------------------------------------------------------\n| CALLABLE: your_function_b | 1      | 2.002      | 2.002      | 0.0     | 0.0     | <built-in method time.sleep>             |\n| LINENO: 9                 |        |            |            |         |         |                                          |\n| FILE: /Users/sonnygeorge/ |        |            |            |         |         |                                          |\n| get-profile/example.py    |        |            |            |         |         |                                          |\n-------------------------------------------------------------------------------------------------------------------------------\n| CALLABLE: your_function_a | 1      | 1.005      | 1.005      | 0.0     | 0.0     | <built-in method time.sleep>             |\n| LINENO: 6                 |        |            |            |         |         |                                          |\n| FILE: /Users/sonnygeorge/ |        |            |            |         |         |                                          |\n| get-profile/example.py    |        |            |            |         |         |                                          |\n-------------------------------------------------------------------------------------------------------------------------------\n```\n\n\nInstallation\n------------\n``get-profile`` can be installed with ``pip``:\n\n    $ pip install get-profile\n\n\nDecorator Parameters\n--------------------\n\nRelease 0.0.2 supports the following parameters for the get_profile decorator:\n\n```python\nget_profile(\n\n# topn limits the table to only the top n rows\ntop_n: int = 10,\n\n# only_my_functions = True will filter out functions whose \n# \"func\" field contains the regex pattern: \n# r\"/python[0-9]+\\.[0-9]+/|<.*>\",\n# (a hacky way to limit the output to just your own functions)\nonly_my_functions: bool = False,  \n\n# sort_by is the column you would like to sort by (descending)\nsort_by: str = \"tottime -r\",\n\n# min_col is the column you would like to filter by (min_val)\nmin_col: str = \"tottime -r\",\n\n# min_val is the minimum value for the min_col\nmin_val: float = 0.005,\n\n# output_width is the width in chars of the output table\noutput_width: int = 150,\n\n# toggles whether or not the \"calees\" column is printed\ncallees: bool = True,\n\n)\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Quickly profile your code with a single line of code.",
    "version": "0.0.2",
    "split_keywords": [
        "python",
        "profiling",
        "profile",
        "runtime",
        "decorator",
        "cprofile"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "126936525bc922abc0514b699a2f5154ee7fc198c9f5ac35a473bad19eee7d79",
                "md5": "42b7b66f2b18c2a08bde26d7732dfff3",
                "sha256": "2f45e1871ef92e60d02672b6143053e70654d04e67b733adb9b5e580f41711f9"
            },
            "downloads": -1,
            "filename": "get_profile-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42b7b66f2b18c2a08bde26d7732dfff3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6065,
            "upload_time": "2023-01-17T23:58:13",
            "upload_time_iso_8601": "2023-01-17T23:58:13.206293Z",
            "url": "https://files.pythonhosted.org/packages/12/69/36525bc922abc0514b699a2f5154ee7fc198c9f5ac35a473bad19eee7d79/get_profile-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c8be931e6f4e367731f818ef155055f0ba5a4d46d25c42fd5e390dbc000ec77",
                "md5": "610c5aa9f0d307e4c9efdf3d1ead8f2b",
                "sha256": "0c0eb7d88cca359d97c269d4e4249efb48d64621af81064f6bef3d832da18b6a"
            },
            "downloads": -1,
            "filename": "get-profile-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "610c5aa9f0d307e4c9efdf3d1ead8f2b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5519,
            "upload_time": "2023-01-17T23:58:15",
            "upload_time_iso_8601": "2023-01-17T23:58:15.338152Z",
            "url": "https://files.pythonhosted.org/packages/0c/8b/e931e6f4e367731f818ef155055f0ba5a4d46d25c42fd5e390dbc000ec77/get-profile-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-17 23:58:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "get-profile"
}
        
Elapsed time: 0.61377s