# Perfometrics
Perfometrics is a Python library for measuring the performance of a given URL using the pycurl library. The library provides various metrics such as HTTP status code, time taken for DNS resolution, time taken for establishing TCP connection, time taken for establishing SSL/TLS connection, time taken for the first byte of the response, time taken for data transfer, and total time taken for the request.
## Installation
To install perfometrics, simply run the following command:
```bash
pip install perfometrics
```
## Usage
To use perfometrics, you can import the curl module and create a CurlUptime object with the URL you want to measure. Here's an example:
```python
import perfometrics.curl as pcurl
url = 'https://example.com'
curl_uptime = pcurl.CurlUptime(url)
metrics = curl_uptime.get_metrics()
print('Metrics for', url)
print('HTTP status code:', metrics['status_code'])
print('Time taken for DNS resolution:', metrics['dns_lookup'], 'seconds')
print('Time taken for establishing TCP connection:', metrics['tcp'], 'seconds')
print('Time taken for establishing SSL/TLS connection:', metrics['ssl_tls'], 'seconds')
print('Time taken for the first byte of the response:', metrics['ttfb'], 'seconds')
print('Time taken for data transfer:', metrics['data_transfer'], 'seconds')
print('Total time taken for the request:', metrics['total'], 'seconds')
```
This will output something like:
```
Metrics for https://example.com
HTTP status code: 200
Time taken for DNS resolution: 0.003439 seconds
Time taken for establishing TCP connection: 0.057725 seconds
Time taken for establishing SSL/TLS connection: 0.09169 seconds
Time taken for the first byte of the response: 0.213251 seconds
Time taken for data transfer: 0.067498 seconds
Total time taken for the request: 0.282891 seconds
```
After you're done with the CurlUptime object, you should call its close_session() method to close the pycurl.Curl() session.
## License
perfometrics is licensed under the GNU General Public License v3.0. See the LICENSE file for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/realxoman/perfometrics",
"name": "perfometrics",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "performance,metrics,testing,speed test",
"author": "Ali Esmaeili",
"author_email": "hi@aliesm.com",
"download_url": "https://files.pythonhosted.org/packages/13/86/42055267de1b8d24ae5eb250a60d742ac0eb4a1e6e91359636c8a4d191fc/perfometrics-0.0.6.tar.gz",
"platform": null,
"description": "# Perfometrics\r\n\r\nPerfometrics is a Python library for measuring the performance of a given URL using the pycurl library. The library provides various metrics such as HTTP status code, time taken for DNS resolution, time taken for establishing TCP connection, time taken for establishing SSL/TLS connection, time taken for the first byte of the response, time taken for data transfer, and total time taken for the request.\r\n\r\n## Installation\r\n\r\nTo install perfometrics, simply run the following command:\r\n\r\n```bash\r\npip install perfometrics\r\n```\r\n\r\n## Usage\r\n\r\nTo use perfometrics, you can import the curl module and create a CurlUptime object with the URL you want to measure. Here's an example:\r\n\r\n```python\r\nimport perfometrics.curl as pcurl\r\n\r\nurl = 'https://example.com'\r\ncurl_uptime = pcurl.CurlUptime(url)\r\nmetrics = curl_uptime.get_metrics()\r\n\r\nprint('Metrics for', url)\r\nprint('HTTP status code:', metrics['status_code'])\r\nprint('Time taken for DNS resolution:', metrics['dns_lookup'], 'seconds')\r\nprint('Time taken for establishing TCP connection:', metrics['tcp'], 'seconds')\r\nprint('Time taken for establishing SSL/TLS connection:', metrics['ssl_tls'], 'seconds')\r\nprint('Time taken for the first byte of the response:', metrics['ttfb'], 'seconds')\r\nprint('Time taken for data transfer:', metrics['data_transfer'], 'seconds')\r\nprint('Total time taken for the request:', metrics['total'], 'seconds')\r\n```\r\n\r\nThis will output something like:\r\n\r\n```\r\nMetrics for https://example.com\r\nHTTP status code: 200\r\nTime taken for DNS resolution: 0.003439 seconds\r\nTime taken for establishing TCP connection: 0.057725 seconds\r\nTime taken for establishing SSL/TLS connection: 0.09169 seconds\r\nTime taken for the first byte of the response: 0.213251 seconds\r\nTime taken for data transfer: 0.067498 seconds\r\nTotal time taken for the request: 0.282891 seconds\r\n```\r\n\r\nAfter you're done with the CurlUptime object, you should call its close_session() method to close the pycurl.Curl() session.\r\n\r\n## License\r\n\r\nperfometrics is licensed under the GNU General Public License v3.0. See the LICENSE file for more information.\r\n",
"bugtrack_url": null,
"license": "",
"summary": "A python library to measure the performance metrics of a website",
"version": "0.0.6",
"split_keywords": [
"performance",
"metrics",
"testing",
"speed test"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a6a6794514043faa2f78df1d163c35e1c66dc6722b80ecad4631b5d779acd7e",
"md5": "2885498b9746d3d771b2753387836f99",
"sha256": "49de1a1ee90a044faff7fe84f82ce0d2cbde32a03aa70acdf4fdb178965856fe"
},
"downloads": -1,
"filename": "perfometrics-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2885498b9746d3d771b2753387836f99",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 17331,
"upload_time": "2023-04-03T15:54:52",
"upload_time_iso_8601": "2023-04-03T15:54:52.697240Z",
"url": "https://files.pythonhosted.org/packages/5a/6a/6794514043faa2f78df1d163c35e1c66dc6722b80ecad4631b5d779acd7e/perfometrics-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "138642055267de1b8d24ae5eb250a60d742ac0eb4a1e6e91359636c8a4d191fc",
"md5": "c230b042dba3fafa10a9f8201e4b1896",
"sha256": "c5cf2f9add5d51c0c342c616155d50951adfc8b38c55ff7e1ac071fa344abf67"
},
"downloads": -1,
"filename": "perfometrics-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "c230b042dba3fafa10a9f8201e4b1896",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 17125,
"upload_time": "2023-04-03T15:54:54",
"upload_time_iso_8601": "2023-04-03T15:54:54.873888Z",
"url": "https://files.pythonhosted.org/packages/13/86/42055267de1b8d24ae5eb250a60d742ac0eb4a1e6e91359636c8a4d191fc/perfometrics-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-03 15:54:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "realxoman",
"github_project": "perfometrics",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "perfometrics"
}