timeitpoj


Nametimeitpoj JSON
Version 0.1.11 PyPI version JSON
download
home_pagehttps://github.com/jvanmelckebeke/timeitpoj
Summaryyet another random library for measuring python performance
upload_time2024-01-05 22:31:43
maintainerJari Van Melckebeke
docs_urlNone
authorJari Van Melckebeke
requires_python>=3.8,<4.0
licenseMIT
keywords timeit performance benchmark time measure
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Timeitpoj

yet another random library for measuring python performance

[![Build and Test](https://github.com/jvanmelckebeke/timeitpoj/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/jvanmelckebeke/timeitpoj/actions/workflows/run-tests.yaml)
[![PyPI version](https://badge.fury.io/py/timeitpoj.svg)](https://badge.fury.io/py/timeitpoj)

## Usage in production

if you do not need to measure performance of your code in a production environment, simply set the environment
variable `TIME_IT` to`false`

#### Example

```python
from timeitpoj.timeit import TimeIt
from time import sleep

BASE_TIME = 0.1

with TimeIt("my timer") as timer:
    print("Executing my timer....")
    sleep(BASE_TIME)

    with timer("my subtimer"):
        print("Executing my subtimer....")
        sleep(BASE_TIME)

        with timer("my nested subtimer"):
            print("Executing my nested subtimer....")
            sleep(BASE_TIME)

            for _ in range(2):
                with timer("my super nested subtimer 2"):
                    sleep(BASE_TIME)

        for _ in range(5):
            with timer("my nested subtimer 2"):
                sleep(BASE_TIME)

    with timer("my subtimer 992"):
        print("Executing my subtimer 2....")
        sleep(BASE_TIME)

    with timer("my subtimer 4"):
        print("Executing my subtimer 4....")
        sleep(BASE_TIME)

    # Something that is not covered by the timer
    sleep(BASE_TIME * 2)
```

#### Output

```
================= [my timer] TIMEIT REPORT =================
[TIMEIT] my timer took 1.403 seconds
└── [81.80%] my subtimer ; 0.902 seconds
    ├── [37.49%] my nested subtimer ; 0.300 seconds
        └── my super nested subtimer 2 ; 0.200 seconds ; 2 times ; avg 0.100 seconds
    └── [62.51%] my nested subtimer 2 ; 0.501 seconds ; 5 times ; avg 0.100 seconds
├── [ 9.12%] my subtimer 992 ; 0.101 seconds
└── [ 9.08%] my subtimer 4   ; 0.100 seconds
└── [ 0.01%] internal time: 0.112 milliseconds
[78.56%% COVERAGE] time accounted for: 1.102 seconds, time unaccounted for: 0.301 seconds
[TIMEIT] report generation took 0.190 milliseconds
================= [my timer] TIMEIT REPORT =================
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jvanmelckebeke/timeitpoj",
    "name": "timeitpoj",
    "maintainer": "Jari Van Melckebeke",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "jarivanmelckebeke@gmail.com",
    "keywords": "timeit,performance,benchmark,time,measure",
    "author": "Jari Van Melckebeke",
    "author_email": "jarivanmelckebeke@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e6/f5/8ee1fce1bade0bcf13d1350f6a35094bfd8b2fda630552f393ac2f46c85f/timeitpoj-0.1.11.tar.gz",
    "platform": null,
    "description": "# Timeitpoj\n\nyet another random library for measuring python performance\n\n[![Build and Test](https://github.com/jvanmelckebeke/timeitpoj/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/jvanmelckebeke/timeitpoj/actions/workflows/run-tests.yaml)\n[![PyPI version](https://badge.fury.io/py/timeitpoj.svg)](https://badge.fury.io/py/timeitpoj)\n\n## Usage in production\n\nif you do not need to measure performance of your code in a production environment, simply set the environment\nvariable `TIME_IT` to`false`\n\n#### Example\n\n```python\nfrom timeitpoj.timeit import TimeIt\nfrom time import sleep\n\nBASE_TIME = 0.1\n\nwith TimeIt(\"my timer\") as timer:\n    print(\"Executing my timer....\")\n    sleep(BASE_TIME)\n\n    with timer(\"my subtimer\"):\n        print(\"Executing my subtimer....\")\n        sleep(BASE_TIME)\n\n        with timer(\"my nested subtimer\"):\n            print(\"Executing my nested subtimer....\")\n            sleep(BASE_TIME)\n\n            for _ in range(2):\n                with timer(\"my super nested subtimer 2\"):\n                    sleep(BASE_TIME)\n\n        for _ in range(5):\n            with timer(\"my nested subtimer 2\"):\n                sleep(BASE_TIME)\n\n    with timer(\"my subtimer 992\"):\n        print(\"Executing my subtimer 2....\")\n        sleep(BASE_TIME)\n\n    with timer(\"my subtimer 4\"):\n        print(\"Executing my subtimer 4....\")\n        sleep(BASE_TIME)\n\n    # Something that is not covered by the timer\n    sleep(BASE_TIME * 2)\n```\n\n#### Output\n\n```\n================= [my timer] TIMEIT REPORT =================\n[TIMEIT] my timer took 1.403 seconds\n\u2514\u2500\u2500 [81.80%] my subtimer ; 0.902 seconds\n    \u251c\u2500\u2500 [37.49%] my nested subtimer ; 0.300 seconds\n        \u2514\u2500\u2500 my super nested subtimer 2 ; 0.200 seconds ; 2 times ; avg 0.100 seconds\n    \u2514\u2500\u2500 [62.51%] my nested subtimer 2 ; 0.501 seconds ; 5 times ; avg 0.100 seconds\n\u251c\u2500\u2500 [ 9.12%] my subtimer 992 ; 0.101 seconds\n\u2514\u2500\u2500 [ 9.08%] my subtimer 4   ; 0.100 seconds\n\u2514\u2500\u2500 [ 0.01%] internal time: 0.112 milliseconds\n[78.56%% COVERAGE] time accounted for: 1.102 seconds, time unaccounted for: 0.301 seconds\n[TIMEIT] report generation took 0.190 milliseconds\n================= [my timer] TIMEIT REPORT =================\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "yet another random library for measuring python performance",
    "version": "0.1.11",
    "project_urls": {
        "Homepage": "https://github.com/jvanmelckebeke/timeitpoj",
        "Repository": "https://github.com/jvanmelckebeke/timeitpoj"
    },
    "split_keywords": [
        "timeit",
        "performance",
        "benchmark",
        "time",
        "measure"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0cdcf75ce8782c27f154b45f8d0f10f4348ae5628041a0340c6088298c96cd86",
                "md5": "f205b786fa6fadeadddbf0a9267a87f6",
                "sha256": "4d5e719b6f94ba2fb8061dc4d442780611dc806224eb774ac21d571e09527bfb"
            },
            "downloads": -1,
            "filename": "timeitpoj-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f205b786fa6fadeadddbf0a9267a87f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 10664,
            "upload_time": "2024-01-05T22:31:41",
            "upload_time_iso_8601": "2024-01-05T22:31:41.601970Z",
            "url": "https://files.pythonhosted.org/packages/0c/dc/f75ce8782c27f154b45f8d0f10f4348ae5628041a0340c6088298c96cd86/timeitpoj-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6f58ee1fce1bade0bcf13d1350f6a35094bfd8b2fda630552f393ac2f46c85f",
                "md5": "cb80e11d62c86a52bed4d97c35bc0111",
                "sha256": "6a5f27b923e98d90f0e9816c1cead3c052e1aa51c4f0ce86fe5be8de264ad371"
            },
            "downloads": -1,
            "filename": "timeitpoj-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "cb80e11d62c86a52bed4d97c35bc0111",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 8049,
            "upload_time": "2024-01-05T22:31:43",
            "upload_time_iso_8601": "2024-01-05T22:31:43.537590Z",
            "url": "https://files.pythonhosted.org/packages/e6/f5/8ee1fce1bade0bcf13d1350f6a35094bfd8b2fda630552f393ac2f46c85f/timeitpoj-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-05 22:31:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jvanmelckebeke",
    "github_project": "timeitpoj",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "timeitpoj"
}
        
Elapsed time: 0.17283s