et-stopwatch


Nameet-stopwatch JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/etijskens/et-stopwatch
SummaryA class for timing code (start/stop, context manager, decorator).
upload_time2023-02-07 13:57:32
maintainer
docs_urlNone
authorEngelbert Tijskens
requires_python>=3.7,<4.0
licenseMIT
keywords packaging poetry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ============
et-stopwatch
============

A class for timing code. A Stopwatch object can be used to time code using its ``start`` and
``stop`` methods::

    from et_stopwatch import Stopwatch

    stopwatch = Stopwatch() # create and start the stopwatch
    sleep(1)
    stopwatch.stop()
    print(stopwatch)

    stopwatch : 1.003744 s

Use as a **context manager**::

    with Stopwatch(message='This took') as sw: # using a custom message
        for i in range(3):
            sleep(1)
            print(i, sw.stop(), 's') # stop() returns the time since the last call to start|stop in seconds

    0 1.004943
    1 1.004948
    2 1.003404
    This took :
        total  : 3.013295 s
        minimum: 1.003404 s
        maximum: 1.004948 s
        mean   : 1.004432 s
        stddev : 0.000727 s
        count  : 3

Since stop was called more than once, some statistics are printed.

Use as a **decorator**::

    @Stopwatch(name="say_hi_and_sleep_two_seconds", ndigits=3) # custom message, print only 3 digits.
    def say_hi_and_sleep_two_seconds():
        print("hi")
        sleep(2)

    say_hi_and_sleep_two_seconds()

    hi
    say_hi_and_sleep_two_seconds : 2.003 s

* Free software: MIT license
* Documentation: https://et-stopwatch.readthedocs.io.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/etijskens/et-stopwatch",
    "name": "et-stopwatch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "packaging,poetry",
    "author": "Engelbert Tijskens",
    "author_email": "engelbert.tijskens@uantwerpen.be",
    "download_url": "https://files.pythonhosted.org/packages/23/c5/ed488f649469e03e4b0b0be40b0054963d2d12498be5bf73a29861dad60c/et_stopwatch-1.3.1.tar.gz",
    "platform": null,
    "description": "============\net-stopwatch\n============\n\nA class for timing code. A Stopwatch object can be used to time code using its ``start`` and\n``stop`` methods::\n\n    from et_stopwatch import Stopwatch\n\n    stopwatch = Stopwatch() # create and start the stopwatch\n    sleep(1)\n    stopwatch.stop()\n    print(stopwatch)\n\n    stopwatch : 1.003744 s\n\nUse as a **context manager**::\n\n    with Stopwatch(message='This took') as sw: # using a custom message\n        for i in range(3):\n            sleep(1)\n            print(i, sw.stop(), 's') # stop() returns the time since the last call to start|stop in seconds\n\n    0 1.004943\n    1 1.004948\n    2 1.003404\n    This took :\n        total  : 3.013295 s\n        minimum: 1.003404 s\n        maximum: 1.004948 s\n        mean   : 1.004432 s\n        stddev : 0.000727 s\n        count  : 3\n\nSince stop was called more than once, some statistics are printed.\n\nUse as a **decorator**::\n\n    @Stopwatch(name=\"say_hi_and_sleep_two_seconds\", ndigits=3) # custom message, print only 3 digits.\n    def say_hi_and_sleep_two_seconds():\n        print(\"hi\")\n        sleep(2)\n\n    say_hi_and_sleep_two_seconds()\n\n    hi\n    say_hi_and_sleep_two_seconds : 2.003 s\n\n* Free software: MIT license\n* Documentation: https://et-stopwatch.readthedocs.io.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A class for timing code (start/stop, context manager, decorator).",
    "version": "1.3.1",
    "split_keywords": [
        "packaging",
        "poetry"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c0f90ff65a40f5ed3639474d8b2598046e947fa3bc02905afc050c5cd79d726",
                "md5": "bec1dcf3adb54c6ce9c93772b153e923",
                "sha256": "7744a22c28301fe9602b4abcb368cb33df3d61d60be9d252c8e5bb576f060dff"
            },
            "downloads": -1,
            "filename": "et_stopwatch-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bec1dcf3adb54c6ce9c93772b153e923",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 5513,
            "upload_time": "2023-02-07T13:57:30",
            "upload_time_iso_8601": "2023-02-07T13:57:30.987483Z",
            "url": "https://files.pythonhosted.org/packages/5c/0f/90ff65a40f5ed3639474d8b2598046e947fa3bc02905afc050c5cd79d726/et_stopwatch-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23c5ed488f649469e03e4b0b0be40b0054963d2d12498be5bf73a29861dad60c",
                "md5": "8ff3c76a73258bf64bd46cecb7cd3a7d",
                "sha256": "6e4bbb86d11476d776f63d062638a69c1ffffd0be4baef8a241df3c5c1176952"
            },
            "downloads": -1,
            "filename": "et_stopwatch-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8ff3c76a73258bf64bd46cecb7cd3a7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 5039,
            "upload_time": "2023-02-07T13:57:32",
            "upload_time_iso_8601": "2023-02-07T13:57:32.812259Z",
            "url": "https://files.pythonhosted.org/packages/23/c5/ed488f649469e03e4b0b0be40b0054963d2d12498be5bf73a29861dad60c/et_stopwatch-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-07 13:57:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "etijskens",
    "github_project": "et-stopwatch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "et-stopwatch"
}
        
Elapsed time: 0.06168s