{ "info": { "author": "Paul Smith", "author_email": "paulsmith@pobox.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: System :: Benchmark" ], "description": "# hwcounter\n\nHighly accurate counter for measuring elapsed time in Python.\n\n## Installation\n\n``` shell\n$ pip install hwcounter\n```\n\n## Overview\n\nThis Python extension module uses the hardware timestamp counter to\nprovide very high precision and accurate measurements of execution\ntime.\n\nThe module exposes three main objects. Two are plain functions,\n`count` and `count_end`, which return the current value of the\ntimestamp counter. They can be used together to manually track the\nstart and end of a timing measurement. The third is the `Timer` type,\nwhich is to be used as a context manager, wrapping a block of code to\nbe measured.\n\nUsing `Timer` to wrap a block of code is to be preferred over\nmanually using `count` and `count_end`. This is for convenience, as well\nas because it factors in the overhead of calling the underlying\nmeasurement instructions.\n\n### `count()`\n\nReturns the current value of the timestamp counter, in cycles.\n\n### `count_end()`\n\nReturns the current value of the timestamp counter, in cycles. It is\nsuitable for use at the end of a timing measurement.\n\n### `Timer`\n\nClass that implements the context manager protocol.\n\n#### `Timer.cycles`\n\nThe `cycles` attribute is populated with the elapsed time, in cycles,\nwhen the Timer context manager exits.\n\n## Example usage\n\n``` python\nfrom hwcounter import Timer, count, count_end\n\nfrom time import sleep\nfrom math import sqrt\n\n\n# 1. Manually count cycles elapsed between two points\n\nstart = count()\nsqrt(144) / 12\nelapsed = count_end() - start\nprint(f'elapsed cycles: {elapsed}')\n# elapsed cycles: 36486\n\n\n# 2. Use Timer object as context manager to wrap a block of code and measure its timing\n\nwith Timer() as t:\n\tsleep(1)\nprint(f'elapsed cycles: {t.cycles}')\n# elapsed cycles: 2912338344\n```\n\nThese examples were performed on an Intel Core i5-6267U CPU @\n2.90GHz. Notice that the sleep for 1 second in the example above\nyields a 2.9 billion cycle count.\n\n## Notes\n\nThe overhead of calling the underlying measurement instructions is\ntaken into account when using the Timer context manager. In other\nwords, the number of cycles it takes to call the machine instructions\nare subtracted from the elapsed cycle count automatically.\n\nThis library returns measurements in processor clock cycles. For\nbenchmarking programs and making apples-to-apples comparisons of\nchanges in code execution time, this method is sufficient and\nreliable. If elapsed time in seconds is desired, a conversion from\nclock cycles is required: divide the cycle count by the processor's\nclock speed (in Hz). This conversion is outside the scope of this\nmodule.\n\n## Portability\n\nThis extension uses the `RDTSC` and `RDTSCP` instructions on the x86\narchitecture, so it won't work on other platforms. It is Python 3\nonly.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/paulsmith/hwcounter", "keywords": "benchmark x86 rdtsc timing", "license": "", "maintainer": "", "maintainer_email": "", "name": "hwcounter", "package_url": "https://pypi.org/project/hwcounter/", "platform": "", "project_url": "https://pypi.org/project/hwcounter/", "project_urls": { "Homepage": "https://github.com/paulsmith/hwcounter" }, "release_url": "https://pypi.org/project/hwcounter/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Highly accurate counter for measuring elapsed time in Python", "version": "0.1.1" }, "last_serial": 3486974, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "bb0ecf1e5f498ed3b0eec10b598c4021", "sha256": "11100d865885f3d352f98649855d34b9be6c6fb97e5a79de7ad92852129d57a5" }, "downloads": -1, "filename": "hwcounter-0.1.0-cp36-cp36m-macosx_10_6_intel.whl", "has_sig": false, "md5_digest": "bb0ecf1e5f498ed3b0eec10b598c4021", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 10610, "upload_time": "2018-01-12T18:04:45", "url": "https://files.pythonhosted.org/packages/76/10/fa1d6ee578d3dc15ae06b4a76fa3f14cea2a7a15f6a0811628fc4ee67c6c/hwcounter-0.1.0-cp36-cp36m-macosx_10_6_intel.whl" }, { "comment_text": "", "digests": { "md5": "fb0f589123578b243b3be253a43cd9df", "sha256": "d9a2e4d54e06e1fac80351840014fad6d17556b1e4345339ce1784f6b049d4c6" }, "downloads": -1, "filename": "hwcounter-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fb0f589123578b243b3be253a43cd9df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4103, "upload_time": "2018-01-12T18:04:51", "url": "https://files.pythonhosted.org/packages/0d/92/eb4c30608f7a5f7e48888ec625412488cfaf62b495ae501491d476739e7a/hwcounter-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "839ed6a5e4f76473cba69bb0ba76a088", "sha256": "c7a4507f2e90be662fca17632b9411e7138cbd300ddb15907baac1d5f924c632" }, "downloads": -1, "filename": "hwcounter-0.1.1-cp36-cp36m-macosx_10_6_intel.whl", "has_sig": false, "md5_digest": "839ed6a5e4f76473cba69bb0ba76a088", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 8186, "upload_time": "2018-01-13T14:43:41", "url": "https://files.pythonhosted.org/packages/06/03/3b9c197b3bb343cf3de30f6595bcdc4431b78b2f0005640ec953cdecb5e6/hwcounter-0.1.1-cp36-cp36m-macosx_10_6_intel.whl" }, { "comment_text": "", "digests": { "md5": "40aa9d7af1ef67cc78a2b03dde1dc64a", "sha256": "cfae7bea05b0d4008e4d32b1734afb9ef05c909e7c80274b0c9e0f8754ddde27" }, "downloads": -1, "filename": "hwcounter-0.1.1.tar.gz", "has_sig": false, "md5_digest": "40aa9d7af1ef67cc78a2b03dde1dc64a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4134, "upload_time": "2018-01-13T14:43:43", "url": "https://files.pythonhosted.org/packages/83/8d/855522fe8beb584e7ce748e551122943607655628c7a4a1be0270e2d8c07/hwcounter-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "839ed6a5e4f76473cba69bb0ba76a088", "sha256": "c7a4507f2e90be662fca17632b9411e7138cbd300ddb15907baac1d5f924c632" }, "downloads": -1, "filename": "hwcounter-0.1.1-cp36-cp36m-macosx_10_6_intel.whl", "has_sig": false, "md5_digest": "839ed6a5e4f76473cba69bb0ba76a088", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 8186, "upload_time": "2018-01-13T14:43:41", "url": "https://files.pythonhosted.org/packages/06/03/3b9c197b3bb343cf3de30f6595bcdc4431b78b2f0005640ec953cdecb5e6/hwcounter-0.1.1-cp36-cp36m-macosx_10_6_intel.whl" }, { "comment_text": "", "digests": { "md5": "40aa9d7af1ef67cc78a2b03dde1dc64a", "sha256": "cfae7bea05b0d4008e4d32b1734afb9ef05c909e7c80274b0c9e0f8754ddde27" }, "downloads": -1, "filename": "hwcounter-0.1.1.tar.gz", "has_sig": false, "md5_digest": "40aa9d7af1ef67cc78a2b03dde1dc64a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4134, "upload_time": "2018-01-13T14:43:43", "url": "https://files.pythonhosted.org/packages/83/8d/855522fe8beb584e7ce748e551122943607655628c7a4a1be0270e2d8c07/hwcounter-0.1.1.tar.gz" } ] }