{ "info": { "author": "Cyril Desjouy", "author_email": "cyril.desjouy@univ-lemans.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introducing bmtools\n===================\n\n|Pypi| |Build| |Licence|\n\n\n.. image:: https://github.com/ipselium/bmtools/blob/master/docs/compare.png\n\n\n**bmtools** provides some tools dedicated to benchmarking.\n\n\nRequirements\n------------\n\n:python: >= 3.7\n:matplotlib: >= 3.0\n:numpy: >= 1.1\n\nInstallation\n------------\n\nClone the github repo and\n\n.. code:: console\n\n $ python setup.py install\n\nor install via Pypi\n\n.. code:: console\n\n $ pip install bmtools\n\n\nCompare execution times\n-----------------------\n\nBenchmarking functions execution can be done with **`Compare`** class as follows:\n\n.. code-block:: python\n\n import numpy as np\n from bmtools import Compare\n\n def star_op(x):\n \"\"\" Double star operator. \"\"\"\n return x**0.5\n\n def pow_op(x):\n \"\"\" pow function. \"\"\"\n return pow(x, 0.5)\n\n def sqrt_op(x):\n \"\"\" numpy.sqrt function. \"\"\"\n return np.sqrt(x)\n\n if __name__ == \"__main__\":\n\n # Single comparison\n bm1 = Compare(pow_op, star_op, sqrt_op)\n bm1.run_single(fargs=(np.random.rand(1000000), ))\n bm1.display()\n\n # Parametric comparison\n bm2 = Compare(pow_op, star_op, sqrt_op, unit='ms')\n for n in [2**n for n in range(16, 23)]:\n bm2.run_single(fargs=(np.random.rand(n), ), desc=n)\n\n bm2.display()\n bm2.bars()\n\n.. code:: console\n\n +------------+---------------+----------------+----------------+-------+\n | Function | Description | Runtime [msec] | Std [msec] | Equal |\n +------------+---------------+----------------+----------------+-------+\n | pow_op | -- | 1.56256 | 0.00798 | R1 |\n | star_op | -- | 1.55787 | 0.00752 | ==R1 |\n | sqrt_op | -- | 1.58628 | 0.04214 | ==R1 |\n +------------+---------------+----------------+----------------+-------+\n\n (...)\n\n**`Compare`** provides three ways to display results:\n\n * As a simple plot with the **`Compare.plot()`** method\n * As a bar chart with the **`Compare.bar()`** method\n * As a text table with the **`Compare.display()`** method\n\n\n**`Compare`** also provides the **`parameters`** decorator to specify a list of\nargs/kwarg that have to be passed to a function for parametric study. The\n**`Compare.run_parametric`** method performs the comparison:\n\n.. code-block:: python\n\n from bmtools import Compare\n\n @Compare.parameters((1, 2,), (2, 3, ), x=(1, 10))\n def op1(a, b, x=1):\n return a*x + b\n\n @Compare.parameters((1, 2,), (2, 3,), x=(1, 10))\n def op2(a, b, x=1):\n return a*x + b\n\n if __name__ == \"__main__\":\n bm3 = Compare(op1, op2, unit='nsec')\n bm3.run_parametric()\n bm3.display()\n\n.. code:: console\n\n +------------+---------------+----------------+----------------+-------+\n | Function | Description | Runtime [nsec] | Std [nsec] | Equal |\n +------------+---------------+----------------+----------------+-------+\n | op1 | 1, 2, x=1 | 398.0 | 22.3 | R1 |\n | op2 | 1, 2, x=1 | 410.1 | 10.4 | ==R1 |\n +------------+---------------+----------------+----------------+-------+\n | op1 | 1, 2, x=10 | 408.5 | 13.7 | R2 |\n | op2 | 1, 2, x=10 | 408.2 | 10.7 | ==R2 |\n +------------+---------------+----------------+----------------+-------+\n | op1 | 2, 3, x=1 | 399.4 | 8.2 | R3 |\n | op2 | 2, 3, x=1 | 401.5 | 3.8 | ==R3 |\n +------------+---------------+----------------+----------------+-------+\n | op1 | 2, 3, x=10 | 392.0 | 17.6 | R4 |\n | op2 | 2, 3, x=10 | 399.1 | 11.5 | ==R4 |\n +------------+---------------+----------------+----------------+-------+\n\n\nTime instance methods\n---------------------\n\nThe **`mtimer`** decorator can be used to time instance methods as follows:\n\n.. code-block:: python\n\n import time\n from bmtools import mtimer\n\n\n class MtimeExample:\n \"\"\" mtimer examples. \"\"\"\n\n def __init__(self):\n self.string = 'mtimer example'\n\n @mtimer(name='with arg')\n def method1(self, string):\n \"\"\" Example with argument. \"\"\"\n time.sleep(0.2)\n print(self.string, string)\n time.sleep(0.2)\n\n @mtimer\n def method2(self, string):\n \"\"\" Example without argument. \"\"\"\n time.sleep(0.1)\n print(self.string, string)\n time.sleep(0.1)\n\n\n if __name__ == \"__main__\":\n\n mt = MtimeExample()\n\n for _ in range(2):\n mt.method1('with argument')\n\n mt.method2('without argument')\n\n format_mtimer(mt)\n\n\nAdd time probes to your code\n----------------------------\n\nThe **`TimeProbes`** class provides a way to time blocks of code. Note that this\nclass is largely inspired by Bench-it.\n\n.. code-block:: python\n\n bm = TimeProbes() # Create our probes\n time.sleep(0.1)\n bm('example') # Create a probe named 'example'\n time.sleep(0.2)\n bm() # Create a probe without name\n\n with bm as my_context: # Use probe as context manager.\n time.sleep(0.8) # my_context will be the name of the probe\n\n bm.display() # Display times measured at probe locations\n\n\n.. code:: console\n\n\n +-------------------------------------------------------------------------------------------------------+\n | TimeProbes |\n + ---------- + ------------------------ + ---------- + ---------------- + ---------------- + ---------- +\n | Makers | File:line | Function | Avg time [msec] | Runtime [msec] | Percent |\n + ---------- + ------------------------ + ---------- + ---------------- + ---------------- + ---------- +\n | example | test_probes_simple.py:33 | -- | 167.75452 | 167.75452 | 14334.3 |\n | Probe 1 | test_probes_simple.py:35 | -- | 201.12324 | 201.12324 | 17185.6 |\n | my_context | test_probes_simple.py:37 | -- | 800.91822 | 800.91822 | 68436.9 |\n + ---------- + ------------------------ + ---------- + ---------------- + ---------------- + ---------- +\n\n\nReferences\n----------\n\nThe **`TimeProbes`** class is largely inpired by Bench-it:\n\nhttps://pypi.org/project/bench-it/\n\n\n\n.. |Pypi| image:: https://badge.fury.io/py/bmtools.svg\n :target: https://pypi.org/project/bmtools\n :alt: Pypi Package\n\n.. |Licence| image:: https://img.shields.io/github/license/ipselium/bmtools.svg\n\n.. |Build| image:: https://travis-ci.org/ipselium/bmtools.svg?branch=master\n :target: https://travis-ci.org/ipselium/bmtools", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ipselium/bmtools", "keywords": "", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "bmtools", "package_url": "https://pypi.org/project/bmtools/", "platform": "", "project_url": "https://pypi.org/project/bmtools/", "project_urls": { "Homepage": "http://github.com/ipselium/bmtools" }, "release_url": "https://pypi.org/project/bmtools/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "System informations", "version": "0.3.1" }, "last_serial": 5995244, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7027406ae8a1c97bd7089639e628e5aa", "sha256": "33f8054a1aab7d6d359ba0247e5ef80fef1870b7f5379e95438db69843c872fb" }, "downloads": -1, "filename": "bmtools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7027406ae8a1c97bd7089639e628e5aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4996, "upload_time": "2019-10-11T14:13:40", "url": "https://files.pythonhosted.org/packages/42/52/31023684f43dfebd13c8388ef5ec4ee2f86c182ecd4441febea20f5058eb/bmtools-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1cf070ed09d06e7f75a6e0ed08616a07", "sha256": "873d104c987401859e0cd3d998c709fab137e3f33573b149554d1eb4995d0903" }, "downloads": -1, "filename": "bmtools-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1cf070ed09d06e7f75a6e0ed08616a07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5384, "upload_time": "2019-10-11T14:48:16", "url": "https://files.pythonhosted.org/packages/48/78/d7a65517a9d5cea3fd7e125146a6f7d7f04f3f5f11183de582aaef9fedec/bmtools-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "1c5275b941a02acbc533de3b3b567145", "sha256": "ce80f9af7a427bcab4e53bb5329ec0f51a324b5ab0415cd0dcff2eb323146d33" }, "downloads": -1, "filename": "bmtools-0.1.2.tar.gz", "has_sig": false, "md5_digest": "1c5275b941a02acbc533de3b3b567145", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5975, "upload_time": "2019-10-11T23:14:50", "url": "https://files.pythonhosted.org/packages/ca/e2/2bb713e9b49644c3fae34ed47bafad3e7683e16e6f89daaf2384aac82572/bmtools-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "6d0dd930b1251db750de821cab85c253", "sha256": "3fa83f4481b95d19a24fb5597e572fca3e5264e70246f72e9204aa046dce5bda" }, "downloads": -1, "filename": "bmtools-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6d0dd930b1251db750de821cab85c253", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5858, "upload_time": "2019-10-13T20:56:55", "url": "https://files.pythonhosted.org/packages/54/d8/3ec8b2449f1a093ffeab89972a9ef5163c9ea57551ba106658bbdc4bb4ae/bmtools-0.1.3.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "0d3abcf711f82cf27f3d204f24317d76", "sha256": "6c1bed3ff5bbda275fd2d6274ca3d633cdf06555c1b23cdd4389ee89607016dd" }, "downloads": -1, "filename": "bmtools-0.1.5.tar.gz", "has_sig": false, "md5_digest": "0d3abcf711f82cf27f3d204f24317d76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8430, "upload_time": "2019-10-14T15:39:48", "url": "https://files.pythonhosted.org/packages/92/65/e9dc40bba9c68442b03dff14ce9b6dc862a129fcfa3852d959a7bbdc77fd/bmtools-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "aa4ca52046863367e879cc3c8e0a0572", "sha256": "9794d2f5c0d08ae2013c12c6da460367cc635a77cf66d0a9b973af273884c45a" }, "downloads": -1, "filename": "bmtools-0.1.6.tar.gz", "has_sig": false, "md5_digest": "aa4ca52046863367e879cc3c8e0a0572", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8436, "upload_time": "2019-10-14T16:03:31", "url": "https://files.pythonhosted.org/packages/5b/d4/abf28a08cb3d2600e2fba832322eecd4332dbc943e980a102b32db11d0c8/bmtools-0.1.6.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "091d3a055f4c99088e04da533b8657e8", "sha256": "cdbfe8e635b36cdf2e64dea12eb150a1423e28b878a311b5a84ae619328febd9" }, "downloads": -1, "filename": "bmtools-0.2.0.tar.gz", "has_sig": false, "md5_digest": "091d3a055f4c99088e04da533b8657e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10124, "upload_time": "2019-10-15T15:17:11", "url": "https://files.pythonhosted.org/packages/ea/5a/dd3e39cde736627b1c621f2af17e9a048c164a0bbd065ebd608080a7f883/bmtools-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "38dfc5a00da552db3cb49ea15184da03", "sha256": "86220b0afb316b8c9b90b97e81396ae4579935e933c9b1b8a7b0eca94971ba0c" }, "downloads": -1, "filename": "bmtools-0.2.1.tar.gz", "has_sig": false, "md5_digest": "38dfc5a00da552db3cb49ea15184da03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12347, "upload_time": "2019-10-16T21:14:09", "url": "https://files.pythonhosted.org/packages/b1/c8/2d22c1a966ce52a796bb64dc786bba3ba555d865a174f5212407b6075fa1/bmtools-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "9c4af8ea79c3cd03e99b433271e22ae7", "sha256": "51a9ab7cf3320ca7f3ae47306753e00647df5d1437ef10aea1107652d8ffbb9a" }, "downloads": -1, "filename": "bmtools-0.3.0.tar.gz", "has_sig": false, "md5_digest": "9c4af8ea79c3cd03e99b433271e22ae7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12667, "upload_time": "2019-10-17T19:11:53", "url": "https://files.pythonhosted.org/packages/a0/f5/d6e2ac5110edceb88d47bf80eaf78762fa182c93fc26c3b08445201cce91/bmtools-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "69b0539f468cc13b34bce96aff43b046", "sha256": "6daaf7dd2aac1049c128c52d39fa9344ba37a0e408c4e3b889ef1e946d4f13b0" }, "downloads": -1, "filename": "bmtools-0.3.1.tar.gz", "has_sig": false, "md5_digest": "69b0539f468cc13b34bce96aff43b046", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13111, "upload_time": "2019-10-18T11:49:29", "url": "https://files.pythonhosted.org/packages/84/d3/e2db9bc6862eaa6673d4f1ea03d099afa44d724c3216866f54275f5bd2e3/bmtools-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69b0539f468cc13b34bce96aff43b046", "sha256": "6daaf7dd2aac1049c128c52d39fa9344ba37a0e408c4e3b889ef1e946d4f13b0" }, "downloads": -1, "filename": "bmtools-0.3.1.tar.gz", "has_sig": false, "md5_digest": "69b0539f468cc13b34bce96aff43b046", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13111, "upload_time": "2019-10-18T11:49:29", "url": "https://files.pythonhosted.org/packages/84/d3/e2db9bc6862eaa6673d4f1ea03d099afa44d724c3216866f54275f5bd2e3/bmtools-0.3.1.tar.gz" } ] }