{ "info": { "author": "Vitor Ramos", "author_email": "ramos.vitor89@gmail.com", "bugtrack_url": null, "classifiers": [ "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3" ], "description": "# Performance Counters api for python\n\n[![Build Status](https://travis-ci.com/VitorRamos/performance_features.svg?branch=master)](https://travis-ci.com/VitorRamos/performance_features)\n\n\n## Table of contents\n\n- [What are the performance counters](#whatis)\n- [The API](#api)\n- [Installation](#install)\n- [Example usage](#usage)\n\n\n\n## What are the performance counters\nPerformance counters are special hardware registers available on most modern CPUs. These registers count the number of certain types of events: such as instructions executed, cache misses suffered, or branches mis-predicted without slowing down the kernel or applications. These registers can also trigger interrupts when a threshold number of events have passed and can thus be used to profile the code that runs on that CPU.\n\n## Reading Performance counters\n+ **Instructions**\n + **rdmsr**: Reads the contents of a 64-bit model specific register (MSR) specified in the ECX register into registers EDX:EAX. This instruction must be executed at privilege level 0 or in real-address mode\n\n + **rdpmc**: Is slightly faster that the equivelent rdmsr instruction. rdpmc can also be configured to allow access to the counters from userspace, without being priviledged.\n+ **From Userspace** (Linux) : The Linux Performance Counter subsystem provides an abstraction of these hardware capabilities. It provides per task and per CPU counters, counter groups, and it provides event capabilities on top of those. It provides \"virtual\" 64-bit counters, regardless of the width of the underlying hardware counters. Performance counters are accessed via special file descriptors. There's one file descriptor per virtual counter used. The special file descriptor is opened via the perf_event_open() system call. These system call do not use rdpmc but rdpmc is not necessarily faster than other methods for reading event values.\n\n\n\n## Python API\nThis module provide a high-level abstraction API to Linux perf events without overhead while executing\n\n## How it works:\nUsing perfmon library python wrapper to perform the system calls and configure the structures to create the file descriptors.\n\nThe file descriptors are passed to the workload module develop on c++ which start the target application and read from the file descriptors\n\n\n\n## Installation\n```bash\nsudo apt install python-dev swig libpfm4-dev\npip install performance-features\n```\n\n\n\n## Usage\n\n### List events\n```python\nfrom profiler import *\n\nprint(get_supported_pmus())\nprint(get_supported_events())\n```\n\n### Sampling events\n```python\nfrom profiler import *\n\ntry:\n events= [['PERF_COUNT_HW_INSTRUCTIONS'],\n ['PERF_COUNT_HW_BRANCH_INSTRUCTIONS','PERF_COUNT_HW_BRANCH_MISSES'],\n ['PERF_COUNT_SW_PAGE_FAULTS']]\n perf= Profiler(program_args= ['/bin/ls','/'], events_groups=events)\n data= perf.run(sample_period= 0.01)\n print(data)\nexcept RuntimeError as e:\n print(e.args[0])\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/VitorRamos/performance_features", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "performance-features", "package_url": "https://pypi.org/project/performance-features/", "platform": "", "project_url": "https://pypi.org/project/performance-features/", "project_urls": { "Homepage": "https://github.com/VitorRamos/performance_features" }, "release_url": "https://pypi.org/project/performance-features/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "perf event wrapper for python", "version": "0.2.0" }, "last_serial": 5676963, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "f341a5c3f1ccf5ef9d17eb1742fcf1bf", "sha256": "c51e34284367ed9aab96ce8328c2dd2deca3187089fca4a41a45734cd9e33a6c" }, "downloads": -1, "filename": "performance_features-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f341a5c3f1ccf5ef9d17eb1742fcf1bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38489, "upload_time": "2018-11-29T10:29:11", "url": "https://files.pythonhosted.org/packages/07/c5/fc33608055d63ee48160cec6d0c5dd200a80a3a07fd2c264f8607ed3304d/performance_features-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "46ebee367254ec6b5c8a2e58ab0cb62d", "sha256": "1912cd2d03a7ad3e22bf18e441a4e6665e35d056ff5f5edb49d91fdba0fd28e4" }, "downloads": -1, "filename": "performance_features-0.1.2.tar.gz", "has_sig": false, "md5_digest": "46ebee367254ec6b5c8a2e58ab0cb62d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38654, "upload_time": "2018-12-13T13:15:23", "url": "https://files.pythonhosted.org/packages/08/23/17eb3e9c9335b16866738846eac2f5e7df03cb89185a28705878f944f795/performance_features-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "e44841024d9358eddd98ddf1dc27cc16", "sha256": "252eead12b0fa61eede1b148f36e37993c41e079ea87bbe366d6b6a1ad66f501" }, "downloads": -1, "filename": "performance_features-0.1.3.tar.gz", "has_sig": false, "md5_digest": "e44841024d9358eddd98ddf1dc27cc16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40682, "upload_time": "2019-08-14T13:09:48", "url": "https://files.pythonhosted.org/packages/b1/c3/05578e6b0d610ca53f12c083430a4b7f00bedb57c122c94c624c5898234a/performance_features-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "23d44eaded02e75e273a13822abc99cf", "sha256": "707a79a9e290994761e35f284eb1f363372f6c4ff955abb6577b8b721d70162a" }, "downloads": -1, "filename": "performance_features-0.2.0.tar.gz", "has_sig": false, "md5_digest": "23d44eaded02e75e273a13822abc99cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40574, "upload_time": "2019-05-27T13:39:29", "url": "https://files.pythonhosted.org/packages/28/a2/ea2a749b96e1a9097b3e4fafbdee1b9717d52514b0f9fb5e76e1879ec7b1/performance_features-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "23d44eaded02e75e273a13822abc99cf", "sha256": "707a79a9e290994761e35f284eb1f363372f6c4ff955abb6577b8b721d70162a" }, "downloads": -1, "filename": "performance_features-0.2.0.tar.gz", "has_sig": false, "md5_digest": "23d44eaded02e75e273a13822abc99cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40574, "upload_time": "2019-05-27T13:39:29", "url": "https://files.pythonhosted.org/packages/28/a2/ea2a749b96e1a9097b3e4fafbdee1b9717d52514b0f9fb5e76e1879ec7b1/performance_features-0.2.0.tar.gz" } ] }