{ "info": { "author": "Zachary Cutlip", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# WITHTIMER\n\n## Description\n\nWithTimer is a Python module for benchmarking your code. It has the following features:\n\n- Simple use\n - Just create a timer object, and it times execution until it goes out of scope\n- Arbitrarily nested timers\n - Create as many nested timers as you want\n - Each timer pushes itself to a stack, and pops itself off when destroyed\n\n## Example usage\n\n```Python\nwith Timer(name=\"Something slow\"):\n do_something_slow()\n```\n\nTiming is turned off by default, and can be optionally turned on. You can instrument your code with timers, and leave them in when you're not using them:\n\n```Python\nif args.enable_timing:\n Timer.enable_timing(args.enable_timing)\nwith Timer(name=\"Timers are a sometimes treat\"):\n do_something()\n```\n\nYou can nest timers:\n\n```Python\nwith Timer(name=\"Outer timer\"):\n for i in range(0, 100000):\n with Timer(name=\"Hope this isn't O(n^2)\"):\n do_something_critical()\n```\n\nHere's a complete example:\n\n```Python\nfrom time import sleep\nfrom withtimer.withtimer import Timer\n\n\ndef func1(count):\n for i in range(0, 3):\n with Timer(name=\"Calling func2\"):\n func2(2)\n print(\"func1 sleeping {}\".format(count))\n sleep(count)\n\n\ndef func2(count):\n print(\"func2 sleeping {}\".format(count))\n sleep(count)\n\n\nif __name__ == \"__main__\":\n Timer.enable_timing(True)\n with Timer(name=\"main\"):\n for i in range(0, 3):\n if i % 2 > 0:\n func1(i+1)\n\n```\n\nOutput:\n\n```console\n$ python3 ./example.py\n[main] start\n [Calling func2] start\nfunc2 sleeping 2\n [Calling func2] end\tElapsed time: 2.003 seconds\n\n [Calling func2] start\nfunc2 sleeping 2\n [Calling func2] end\tElapsed time: 2.003 seconds\n\n [Calling func2] start\nfunc2 sleeping 2\n [Calling func2] end\tElapsed time: 2.003 seconds\n\nfunc1 sleeping 2\n[main] end\tElapsed time: 8.015 seconds\n$\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zcutlip/withtimer", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "withtimer", "package_url": "https://pypi.org/project/withtimer/", "platform": "", "project_url": "https://pypi.org/project/withtimer/", "project_urls": { "Homepage": "https://github.com/zcutlip/withtimer" }, "release_url": "https://pypi.org/project/withtimer/0.1.0.dev1/", "requires_dist": null, "requires_python": ">=2.7", "summary": "Simple Python Timer class you can wrap around blocks of code you want to benchmark", "version": "0.1.0.dev1" }, "last_serial": 5920994, "releases": { "0.1.0.dev0": [ { "comment_text": "", "digests": { "md5": "3a8ee154a3dd3eb7e6874f92d91e505a", "sha256": "e258681e5dd533ff1662fd6e305ab4a195bebabb441ee13d9f59bd4022e2741e" }, "downloads": -1, "filename": "withtimer-0.1.0.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "3a8ee154a3dd3eb7e6874f92d91e505a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7", "size": 4953, "upload_time": "2019-10-02T22:58:06", "url": "https://files.pythonhosted.org/packages/2f/f6/619b25627a24f17e8dc822a2dea112fbdf07b7334c6dee1f952b01832766/withtimer-0.1.0.dev0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d63559f5cd32c68c8299a725c44e819", "sha256": "cf474ae3aaa4f50cbdffbbc610103bb82b1f4e44ca8c18e9d4b12dfba546581c" }, "downloads": -1, "filename": "withtimer-0.1.0.dev0.tar.gz", "has_sig": false, "md5_digest": "2d63559f5cd32c68c8299a725c44e819", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 3137, "upload_time": "2019-10-02T22:58:10", "url": "https://files.pythonhosted.org/packages/2f/ed/be53ea1f31db3d19ec482fa0f6cd1c51763d0a49acb56a39b8d74ab1691c/withtimer-0.1.0.dev0.tar.gz" } ], "0.1.0.dev1": [ { "comment_text": "", "digests": { "md5": "e67f65796601bc000f9f13eb292fd778", "sha256": "129aec4434bb6f2adeae5bbd6dcae383a58ee1b28e6039440a8f24262f29c966" }, "downloads": -1, "filename": "withtimer-0.1.0.dev1-py3-none-any.whl", "has_sig": false, "md5_digest": "e67f65796601bc000f9f13eb292fd778", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7", "size": 5039, "upload_time": "2019-10-02T23:07:40", "url": "https://files.pythonhosted.org/packages/6e/3a/a6127772d321c5faa8e180b2c2ced5ac8537a45bb5b8745706ae99c96b02/withtimer-0.1.0.dev1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a96456cfc2850df064e051e3aa639601", "sha256": "10440efb6121f6be50da0a3354f938c694d7d50058d596a5a9fe59a5d97dcadd" }, "downloads": -1, "filename": "withtimer-0.1.0.dev1.tar.gz", "has_sig": false, "md5_digest": "a96456cfc2850df064e051e3aa639601", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 3266, "upload_time": "2019-10-02T23:07:42", "url": "https://files.pythonhosted.org/packages/0e/73/3968a43af63c06fddf02aec7527b1f1881acf793e448e2a60bdf90f0316d/withtimer-0.1.0.dev1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e67f65796601bc000f9f13eb292fd778", "sha256": "129aec4434bb6f2adeae5bbd6dcae383a58ee1b28e6039440a8f24262f29c966" }, "downloads": -1, "filename": "withtimer-0.1.0.dev1-py3-none-any.whl", "has_sig": false, "md5_digest": "e67f65796601bc000f9f13eb292fd778", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7", "size": 5039, "upload_time": "2019-10-02T23:07:40", "url": "https://files.pythonhosted.org/packages/6e/3a/a6127772d321c5faa8e180b2c2ced5ac8537a45bb5b8745706ae99c96b02/withtimer-0.1.0.dev1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a96456cfc2850df064e051e3aa639601", "sha256": "10440efb6121f6be50da0a3354f938c694d7d50058d596a5a9fe59a5d97dcadd" }, "downloads": -1, "filename": "withtimer-0.1.0.dev1.tar.gz", "has_sig": false, "md5_digest": "a96456cfc2850df064e051e3aa639601", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 3266, "upload_time": "2019-10-02T23:07:42", "url": "https://files.pythonhosted.org/packages/0e/73/3968a43af63c06fddf02aec7527b1f1881acf793e448e2a60bdf90f0316d/withtimer-0.1.0.dev1.tar.gz" } ] }