{ "info": { "author": "Antoine Grigis", "author_email": "antoine.grigis@cea.fr", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development" ], "description": ".. contents::\n\n.. image:: https://travis-ci.org/AGrigis/bredala.svg?branch=master\n :target: https://travis-ci.org/AGrigis/bredala\n\n\n.. image:: https://coveralls.io/repos/AGrigis/bredala/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/AGrigis/bredala\n\n\nEasy to use pure-python caller signature and profiler.\nBased on Pelletier's pprofile_.\n\nOverview\n========\n\nWith Python's standard profiling tools, it is not possible to tell\ndynamically which function is a hot-spot. On top of that the resulting\nexecution ioutput is not filtered and the information of interest may be\ndifficult to find. Those drawbacks made me start 'bredala' which provide:\n\n- A dynamic API to define which functions/methods to follow (based on the 'New\n Import Hooks' PEP0302_.\n\n- A signature mechanism that display the prototype of the called\n function/method.\n\n- A filtered profile to access quickly to the execution time of interest.\n\nUsage\n=====\n\nThe proposed module display function signatures and by default function line\nprofiles. The lattest option can be disabled::\n\n import bredala\n bredala.USE_PROFILER = False\n\nAt the beginning of your script import the project and select which\nfunctions/methods have to be profiled (it must be done before all imports)::\n\n import bredala\n bredala.register(\"bredala.demo.myfunctions\", names=[\"addition\",\n \"substraction\"])\n from bredala.demo.myfunctions import addition, substraction, factorial\n addition(2, 1)\n substraction(2, 1)\n factorial(5)\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.addition...\n addition(a=2, b=1)\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 11| 1| 3.69549e-05| 3.69549e-05| 13.15%|def addition(a, b):\n 12| 0| 0| 0| 0.00%| \"\"\" Demonstration function.\n 13| 0| 0| 0| 0.00%| \"\"\"\n 14| 1| 5.00679e-05| 5.00679e-05| 17.81%| return a + b\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.substraction...\n substraction(a=2, b=1)\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 17| 1| 3.00407e-05| 3.00407e-05| 13.17%|def substraction(a, b):\n 18| 0| 0| 0| 0.00%| \"\"\" Demonstration function.\n 19| 0| 0| 0| 0.00%| \"\"\"\n 20| 1| 3.00407e-05| 3.00407e-05| 13.17%| return a - b\n ____________________________________________________________________0.0s, 0.0min\n\n\nIt is possilbe to profile all the functions/methods of a module by removing\nthe optional 'names' argument. In another script::\n\n import bredala\n bredala.USE_PROFILER = False\n bredala.register(\"bredala.demo.myfunctions\")\n bredala.register(\"bredala.demo.myclasses\")\n from bredala.demo.myfunctions import addition, substraction, factorial\n from bredala.demo.myclasses import Square, Triangle\n addition(2, 1)\n substraction(2, 1)\n factorial(2)\n o = Square(\"my_square\")\n o.area(2)\n o = Triangle(\"my_square\")\n o.area(2, 3)\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.addition...\n addition(a=2, b=1)\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.substraction...\n substraction(a=2, b=1)\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.factorial...\n factorial(a=2)\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myfunctions.factorial...\n factorial(a=1)\n ____________________________________________________________________0.0s, 0.0min\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Square.__init__...\n __init__(self=, name='my_square')\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Square.area...\n area(self=, length_of_side=2)\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Triangle.__init__...\n __init__(self=, name='my_square')\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Triangle.area...\n area(self=, base=2, vertical_height=3)\n ____________________________________________________________________0.0s, 0.0min\n\n\nFor classes we can select to follow all the methods of a class::\n\n import bredala\n bredala.register(\"bredala.demo.myclasses\", names=[\"Square\"])\n from bredala.demo.myclasses import Square, Triangle\n o = Square(\"my_square\")\n o.area(2)\n o = Triangle(\"my_square\")\n o.area(2, 3)\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Square.__init__...\n __init__(self=, name='my_square')\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 14| 1| 3.40939e-05| 3.40939e-05| 17.40%| def __init__(self, name):\n 15| 1| 2.69413e-05| 2.69413e-05| 13.75%| self.name = name\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Square.area...\n area(self=, length_of_side=2)\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 24| 1| 2.09808e-05| 2.09808e-05| 13.19%| def area(self, length_of_side):\n 25| 1| 2.09808e-05| 2.09808e-05| 13.19%| return length_of_side ** 2\n ____________________________________________________________________0.0s, 0.0min\n\nOr we can select to follow specific methods::\n\n import bredala\n bredala.register(\"bredala.demo.myclasses\", names=[\"Square.area\",\n \"Triangle.area\"])\n from bredala.demo.myclasses import Square, Triangle\n o = Square(\"my_square\")\n o.area(2)\n o = Triangle(\"my_square\")\n o.area(2, 3)\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Square.area...\n area(self=, length_of_side=2)\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 24| 1| 3.38554e-05| 3.38554e-05| 17.09%| def area(self, length_of_side):\n 25| 1| 2.6226e-05| 2.6226e-05| 13.24%| return length_of_side ** 2\n ____________________________________________________________________0.0s, 0.0min\n ________________________________________________________________________________\n [bredala] Calling bredala.demo.myclasses.Triangle.area...\n area(self=, base=2, vertical_height=3)\n Line #| Hits| Time| Time per hit| %|Source code\n ------+----------+-------------+-------------+-------+-----------\n 31| 1| 2.09808e-05| 2.09808e-05| 12.94%| def area(self, base, vertical_height):\n 32| 1| 2.09808e-05| 2.09808e-05| 12.94%| return 0.5 * base * vertical_height\n ____________________________________________________________________0.0s, 0.0min\n\nPerspectives\n============\n\nIt will be nice to configure which functions/modules are followed on the fly.\n\n.. _pprofile: https://github.com/vpelletier/pprofile\n.. _PEP0302: https://www.python.org/dev/peps/pep-0302/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/AGrigis/bredala", "keywords": null, "license": "GPL 2+", "maintainer": null, "maintainer_email": null, "name": "bredala", "package_url": "https://pypi.org/project/bredala/", "platform": "any", "project_url": "https://pypi.org/project/bredala/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/AGrigis/bredala" }, "release_url": "https://pypi.org/project/bredala/1.0.1/", "requires_dist": null, "requires_python": null, "summary": ".. image:: https://travis-ci.org/AGrigis/bredala.svg?branch=master", "version": "1.0.1" }, "last_serial": 1701857, "releases": { "1.0.0": [], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d0d1038fc7160a0a73ece1b21bcca711", "sha256": "53058ae8929c7090b67b39e671c2da39f6fd72937dddd5d0810acc2167a3a73d" }, "downloads": -1, "filename": "bredala-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d0d1038fc7160a0a73ece1b21bcca711", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8661, "upload_time": "2015-08-31T16:38:33", "url": "https://files.pythonhosted.org/packages/05/11/cc89dd343316d2231a47febd3db721f2920d22e1e39f4674577b22367e9f/bredala-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d0d1038fc7160a0a73ece1b21bcca711", "sha256": "53058ae8929c7090b67b39e671c2da39f6fd72937dddd5d0810acc2167a3a73d" }, "downloads": -1, "filename": "bredala-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d0d1038fc7160a0a73ece1b21bcca711", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8661, "upload_time": "2015-08-31T16:38:33", "url": "https://files.pythonhosted.org/packages/05/11/cc89dd343316d2231a47febd3db721f2920d22e1e39f4674577b22367e9f/bredala-1.0.1.tar.gz" } ] }