<h1 align="center">
ntropy - Human readable function time measuring
</h1>
<p align="center">
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/cacauisadog/ntropy?color=blueviolet" />
<img alt="Code language count" src="https://img.shields.io/github/languages/count/cacauisadog/ntropy?color=blue" />
<img alt="GitHub top language" src="https://img.shields.io/github/languages/top/cacauisadog/ntropy?color=blue" />
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/cacauisadog/ntropy?color=brightgreen" />
</p>
<h3 align="center">
<a href="#%EF%B8%8F-about">About</a>
<span> · </span>
<a href="#%EF%B8%8F-usage">Usage</a>
<span> · </span>
<a href="#-testing">Testing</a>
</h3>
---
## 🗣️ About
A very simple utility to decorate your functions with that shows you how long that function took to run. Zero dependencies, uses only what Python already gives you.
## 🛠️ Usage
### Requirements
- python >= 3.8 (for TypedDict support)
### Usage instructions
1. Install this package with `pip install ntropy-timer`;
2. Import the `measure_time` function and decorate the function you wish to measure:
```python
from ntropy import measure_time
###
@measure_time
def measure_this_function(*args, **kwargs):
# do something
```
3. Then just execute the function and you should see the results in the standard output:
```python
measure_this_function()
# > The function 'measure_this_function' took 12 seconds 389 miliseconds to run.
```
#### Parameters
##### Disabling the gargabe collector for more precise measurements: `disable_gc` (default: `False`)
With the `disable_gc` flag, you can temporarily disable Python's garbage collector while the decorated function runs. This can be useful for more accurately measuring time specific to that function, tuning outside noise down to a minimum.
##### Showing a more straightforward run time message: `message_format` (possible values: `"human", "complete"`; default: `"human"`)
If you'd like to see a more standard message, showing even zero values, you can pass in the `message_format="complete"` parameter. It will go from:
```
The function 'measure_this_function' took 3 minutes 33 seconds 123 miliseconds to run.
```
to
```
The function 'measure_this_function' took 0hr 3min 33sec 123ms to run.
```
## 📋 Developing
### Requirements
`ntropy` has no requirements to run, but it has to be developed. Clone this repository and install the dev requirements with
```
pip install -r dev-requirements.txt
```
### Testing
To run tests (after installing dev dependencies):
```
pytest
```
Raw data
{
"_id": null,
"home_page": "https://github.com/cacauisadog/ntropy",
"name": "ntropy-timer",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "profiling tuning",
"author": "Cau\u00ea Bittencourt Carnietto",
"author_email": "cbcaue@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/80/31/c3924b51fab2d61e3bcb96745bdb52ba508ca255b76ad03c0203b6eaa8da/ntropy-timer-0.0.2.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">\n ntropy - Human readable function time measuring\n</h1>\n\n<p align=\"center\">\n\t<img alt=\"GitHub code size in bytes\" src=\"https://img.shields.io/github/languages/code-size/cacauisadog/ntropy?color=blueviolet\" />\n\t<img alt=\"Code language count\" src=\"https://img.shields.io/github/languages/count/cacauisadog/ntropy?color=blue\" />\n\t<img alt=\"GitHub top language\" src=\"https://img.shields.io/github/languages/top/cacauisadog/ntropy?color=blue\" />\n\t<img alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/cacauisadog/ntropy?color=brightgreen\" />\n</p>\n\n<h3 align=\"center\">\n\t<a href=\"#%EF%B8%8F-about\">About</a>\n\t<span> \u00b7 </span>\n\t<a href=\"#%EF%B8%8F-usage\">Usage</a>\n\t<span> \u00b7 </span>\n\t<a href=\"#-testing\">Testing</a>\n</h3>\n\n---\n\n\n## \ud83d\udde3\ufe0f About\n\nA very simple utility to decorate your functions with that shows you how long that function took to run. Zero dependencies, uses only what Python already gives you.\n\n\n## \ud83d\udee0\ufe0f Usage\n\n### Requirements\n\n- python >= 3.8 (for TypedDict support)\n\n### Usage instructions\n\n1. Install this package with `pip install ntropy-timer`;\n2. Import the `measure_time` function and decorate the function you wish to measure:\n\n```python\nfrom ntropy import measure_time\n###\n\n@measure_time\ndef measure_this_function(*args, **kwargs):\n\t\t# do something\n```\n\n3. Then just execute the function and you should see the results in the standard output:\n\n```python\nmeasure_this_function()\n\n# > The function 'measure_this_function' took 12 seconds 389 miliseconds to run.\n```\n\n#### Parameters\n##### Disabling the gargabe collector for more precise measurements: `disable_gc` (default: `False`)\nWith the `disable_gc` flag, you can temporarily disable Python's garbage collector while the decorated function runs. This can be useful for more accurately measuring time specific to that function, tuning outside noise down to a minimum.\n\n##### Showing a more straightforward run time message: `message_format` (possible values: `\"human\", \"complete\"`; default: `\"human\"`)\nIf you'd like to see a more standard message, showing even zero values, you can pass in the `message_format=\"complete\"` parameter. It will go from:\n```\nThe function 'measure_this_function' took 3 minutes 33 seconds 123 miliseconds to run.\n```\n\nto\n\n```\nThe function 'measure_this_function' took 0hr 3min 33sec 123ms to run.\n```\n\n## \ud83d\udccb Developing\n\n### Requirements\n`ntropy` has no requirements to run, but it has to be developed. Clone this repository and install the dev requirements with\n\n```\npip install -r dev-requirements.txt\n```\n\n### Testing\nTo run tests (after installing dev dependencies):\n\n```\npytest\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Human readable function time measuring.",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://github.com/cacauisadog/ntropy"
},
"split_keywords": [
"profiling",
"tuning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8031c3924b51fab2d61e3bcb96745bdb52ba508ca255b76ad03c0203b6eaa8da",
"md5": "1e72ea9bd43e393aad3a30744f0962ce",
"sha256": "09ab1ab17916b55acd68467d613cca57056282b7fb87953827de96da75b312be"
},
"downloads": -1,
"filename": "ntropy-timer-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "1e72ea9bd43e393aad3a30744f0962ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4149,
"upload_time": "2023-12-11T17:44:21",
"upload_time_iso_8601": "2023-12-11T17:44:21.915607Z",
"url": "https://files.pythonhosted.org/packages/80/31/c3924b51fab2d61e3bcb96745bdb52ba508ca255b76ad03c0203b6eaa8da/ntropy-timer-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-11 17:44:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cacauisadog",
"github_project": "ntropy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ntropy-timer"
}