Skip to main content

A python library to measure the performance metrics of a website

Project description

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:

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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perfometrics-0.0.6.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

perfometrics-0.0.6-py3-none-any.whl (17.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page