{ "info": { "author": "Viacheslav Kroilov", "author_email": "slavakroilov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", "Topic :: Utilities" ], "description": "Region Profiler - handy Python profiler\n#######################################\n\n.. image:: https://badge.fury.io/py/region-profiler.svg\n :target: https://badge.fury.io/py/region-profiler\n.. image:: https://readthedocs.org/projects/region-profiler/badge/?version=latest\n :target: https://region-profiler.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n.. image:: https://travis-ci.com/metopa/region_profiler.svg?branch=master\n :target: https://travis-ci.com/metopa/region_profiler\n.. image:: https://codecov.io/gh/metopa/region_profiler/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/metopa/region_profiler\n\nMark regions using ``with``-statements and decorators.\nTime region hierarchy and get detailed console report as well as Chrome Trace log.\n\nFeatures\n========\n\n- **Measure only what you need.** See timing for regions you've marked\n and never waste time on looking at things you're not interested in.\n- **Measure third party libraries.** You can mark regions inside arbitrary Python package.\n Just don't forget to rollback changes after you've done :)\n Again, only marked regions count. No need to see timings for unfamiliar library internals.\n- **No need to use external tools** (like kernprof) to gather profiling data.\n Profile from within your application and use usual command to run it.\n- **Average region overhead is 3-10 us** (Python 3.7, Intel Core i5).\n- **Chrome Trace log generation.**\n- **Table or CSV report format.**\n- **No dependencies.**\n\n\nWhy another Python profiler\n===========================\n\nWhile other profilers often focus\non some particular granularity (e.g. function or single line),\nRegion Profiler allows user to choose the size of the scope of interest\neach time, moving from whole function to a subset of lines to a single iteration.\n\nRegion Profiler report\ncontains information only about user-defined regions --\nif we are investigating some complicated framework, we don't need to\ntime its internals outside of the region that we're interested in.\n\nIn contrary to majority of existing profilers,\nRegion Profiler does not require any special programs/switches\n(like kernprof) for application start.\nThis tool is very useful for investigating bottlenecks\nof bigger applications, that has complicated start process\n(e.g. distributed NN trainer, that is run on a cluster using MPI).\n\nGetting started\n===============\n\nDependencies\n------------\n\n- Python >= 3.4\n\n\nInstallation\n------------\n\nYou can install Region Profiler using ``pip``::\n\n pip install region_profiler\n\nor from sources::\n\n git clone https://github.com/metopa/region_profiler.git\n cd region_profiler\n python setup.py install\n\nExample\n-------\n\nMark some code regions for profiling::\n\n import region_profiler as rp # <<<<<\n\n class NeuralNet(tfe.Network):\n def __init__(self):\n ...\n\n def call(self, x):\n with rp.region('NN', asglobal=True): # <<<<<\n with rp.region('layer 1'): # <<<<<\n x = self.layer1(x)\n with rp.region('layer 2'): # <<<<<\n x = self.layer2(x)\n with rp.region('out layer'): # <<<<<\n x = self.out_layer(x)\n return x\n\n @rp.func() # <<<<<\n def loss_fn(inference_fn, inputs, labels):\n ...\n\n @rp.func() # <<<<<\n def accuracy_fn(inference_fn, inputs, labels):\n ...\n\n with rp.region('train'): # <<<<<\n for step in range(num_steps):\n with rp.region('forward'): # <<<<<\n batch_loss = loss_fn(neural_net, x_batch, y_batch)\n batch_accuracy = accuracy_fn(neural_net, x_batch, y_batch)\n with rp.region('backward'): # <<<<<\n optimizer.apply_gradients(grad(neural_net, x_batch, y_batch))\n\nEnable profiling by calling ``region_profiler.install``::\n\n if __name__ == '__main__':\n rp.install(chrome_trace_file='trace.json')\n\nSee console report and flame graph in Chrome Trace Viewer::\n\n name total % of total\n ------------------- -------- ----------\n
12.44 s 100.00%\n . train 11.64 s 93.51%\n . . backward 7.229 s 58.10%\n . . . loss_fn() 2.079 s 16.71%\n . . forward 4.142 s 33.29%\n . . . loss_fn() 2.134 s 17.15%\n . . . accuracy_fn() 1.937 s 15.56%\n . . fetch_next 225.2 ms 1.81%\n . NN 5.389 s 43.32%\n . . layer 1 3.295 s 26.48%\n . . layer 2 1.544 s 12.41%\n . . out layer 444.0 ms 3.57%\n\n.. image:: https://github.com/metopa/region_profiler/raw/master/examples/chrome_tracing.png\n\n\n\nDocumentation\n=============\n\nYou can find complete API reference `here `_.\n\nThe main API consists of these functions:\n\n``region_profiler.install()``\n This function should be called once to enable profiling\n and pass some options to the profiler.\n\n``region_profiler.region()``\n This function returns a context manager that is used to mark a profiling region.\n Allowed parameters:\n\n - ``name`` - region name.\n If omitted, an automatic name in format ``func() `` is used.\n - ``as_global`` - mark region as global.\n\n``region_profiler.func()``\n Function decorator that wraps the marked function in a region.\n Allowed parameters:\n\n - ``name`` - region name.\n If omitted, an automatic name in format ``func()`` is used.\n - ``as_global`` - mark region as global.\n\n``region_profiler.iter_proxy()``\n Iterable object wrapper. Measures time spent in ``__next__`` on each iteration.\n This wrapper is useful, when iterating over things like ``DataLoader``.\n Allowed parameters:\n\n - ``name`` - region name.\n If omitted, an automatic name in format ``func() `` is used.\n - ``as_global`` - mark region as global.\n\n\nLicense\n=======\nMIT \u00a9 Viacheslav Kroilov \n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/metopa/region_profiler", "keywords": "timing,timer,profiling,profiler", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "region-profiler", "package_url": "https://pypi.org/project/region-profiler/", "platform": "", "project_url": "https://pypi.org/project/region-profiler/", "project_urls": { "Homepage": "https://github.com/metopa/region_profiler" }, "release_url": "https://pypi.org/project/region-profiler/0.9.3/", "requires_dist": null, "requires_python": "", "summary": "Profile user-defined regions of code without any external tools", "version": "0.9.3" }, "last_serial": 4973575, "releases": { "0.5.6": [ { "comment_text": "", "digests": { "md5": "691909ee2ba38e1023e0b7b61702cfeb", "sha256": "4a5b2392e7307495ab6f30d55d2555e38dd877c9038cabb5ab95a70ab5777ee7" }, "downloads": -1, "filename": "region_profiler-0.5.6.tar.gz", "has_sig": false, "md5_digest": "691909ee2ba38e1023e0b7b61702cfeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 221639, "upload_time": "2019-02-08T09:56:00", "url": "https://files.pythonhosted.org/packages/0b/c2/73bf0ccb6a418c2554dfba7ee0f72eb3708fabf792b56895e29c4a8a2340/region_profiler-0.5.6.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "5bfd8a5565748d0056e06a980278f926", "sha256": "8bd87623d691cacb451652f53e15de739d8b22f9ef2a8dc14a2ad00c54a4797f" }, "downloads": -1, "filename": "region_profiler-0.9.tar.gz", "has_sig": false, "md5_digest": "5bfd8a5565748d0056e06a980278f926", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 223898, "upload_time": "2019-02-08T11:26:09", "url": "https://files.pythonhosted.org/packages/dc/d6/2fa077598184b2f3a4ed75928ca79304cf2ffee430c87c1532ddadba14bf/region_profiler-0.9.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "082bb20f65694dfbc65d315f8b54ac6b", "sha256": "051c30670daf3bc4c1df6a7635e7a1c3ec97da834ec50cf1ba489f96428fa80a" }, "downloads": -1, "filename": "region_profiler-0.9.1.tar.gz", "has_sig": false, "md5_digest": "082bb20f65694dfbc65d315f8b54ac6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 223930, "upload_time": "2019-02-08T13:15:33", "url": "https://files.pythonhosted.org/packages/54/fd/b7e4d73eda80024d45b27e0366ac84e933c590634d753e16bb12105605c2/region_profiler-0.9.1.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "c9ba147be365efe1d8e8c6beb997f3d1", "sha256": "8bed088c2d9d0ee5a55d21e9482740b5335bf8095680df5127970e727ecb8b2c" }, "downloads": -1, "filename": "region_profiler-0.9.2.tar.gz", "has_sig": false, "md5_digest": "c9ba147be365efe1d8e8c6beb997f3d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 223929, "upload_time": "2019-02-08T13:22:12", "url": "https://files.pythonhosted.org/packages/67/8c/17cdff58a79eac9fc9a6513135cc1ff4a23023fa60d5a682da0b78f992f4/region_profiler-0.9.2.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "a2615b90cb0945ab983cb72ed7b33d26", "sha256": "e9fb0eafff4a3690f64caa648d001dc95ba3a2cc4f81d4a10ecb71571d979093" }, "downloads": -1, "filename": "region_profiler-0.9.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a2615b90cb0945ab983cb72ed7b33d26", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19589, "upload_time": "2019-03-22T16:53:09", "url": "https://files.pythonhosted.org/packages/56/0c/2ab4d71cc17e518d6ec1273440a59eadd073288ace86ec4dc69916c3e58e/region_profiler-0.9.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9a3ff7443df6b7cefed133b0c0a30c3", "sha256": "97adaca10647b44940e5bc1592f7d94494db6ab47691ff17ff7c88dd15b64c02" }, "downloads": -1, "filename": "region_profiler-0.9.3.tar.gz", "has_sig": false, "md5_digest": "e9a3ff7443df6b7cefed133b0c0a30c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15471, "upload_time": "2019-03-22T16:53:10", "url": "https://files.pythonhosted.org/packages/e1/6b/9117d89b1b75af2bc32993ccf693934d0a29533a5a1c704458921fb1e5db/region_profiler-0.9.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a2615b90cb0945ab983cb72ed7b33d26", "sha256": "e9fb0eafff4a3690f64caa648d001dc95ba3a2cc4f81d4a10ecb71571d979093" }, "downloads": -1, "filename": "region_profiler-0.9.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a2615b90cb0945ab983cb72ed7b33d26", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19589, "upload_time": "2019-03-22T16:53:09", "url": "https://files.pythonhosted.org/packages/56/0c/2ab4d71cc17e518d6ec1273440a59eadd073288ace86ec4dc69916c3e58e/region_profiler-0.9.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9a3ff7443df6b7cefed133b0c0a30c3", "sha256": "97adaca10647b44940e5bc1592f7d94494db6ab47691ff17ff7c88dd15b64c02" }, "downloads": -1, "filename": "region_profiler-0.9.3.tar.gz", "has_sig": false, "md5_digest": "e9a3ff7443df6b7cefed133b0c0a30c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15471, "upload_time": "2019-03-22T16:53:10", "url": "https://files.pythonhosted.org/packages/e1/6b/9117d89b1b75af2bc32993ccf693934d0a29533a5a1c704458921fb1e5db/region_profiler-0.9.3.tar.gz" } ] }