Skip to main content

A library to measure your method, function execution time.

Project description

PY Profiler

A library to measure method, function or your restful api execution time.

Install

  • Run pip install py-profiler or pip3 install py-profiler to install this library

Usage

It comes with a really easy api to use, you can add profiler(name = None) decorator to any method or function you want to measure its execution time.

E.g:

from src.py_profiler import profiler


@profiler('hello')
def hello():
    print('hello')

Access Profiler

  • Exec time is in milliseconds
  1. View as a table
from py_profiler import profiling_service

print(profiling_service.as_table())
No Name Total Req Pending Req Total Exec Time Last Exec Time Highest Exec Time Request Rate (req/sec) Avg Time/Request (millis/req)
1 hello 4 0 0.046 0.005 0.029 86956.522 0.011
  1. Integrate with Flask
  • If you are using Flask to implement your Restful API. You can add profiler_blueprint to your Flash app.

E.g:

from flask import Flask
from waitress import serve
from py_profiler import profiler_blueprint

app = Flask(__name__)
app.register_blueprint(profiler_blueprint)

serve(
    app,
    host="0.0.0.0",
    port=8080
)

Then you can access the profiler page at: http://127.0.0.1:8080/profiler Py Profiler Page

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

py_profiler-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

py_profiler-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file py_profiler-0.1.2.tar.gz.

File metadata

  • Download URL: py_profiler-0.1.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.6

File hashes

Hashes for py_profiler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9a391f09643d9ad473b44a759735a57998d1deba012e8d33547ad2df3832fe3a
MD5 948f6bc135fe39afde8a59fb70ceb80a
BLAKE2b-256 dc15c1b00e5108ff85ba6587fe69ec1540815a3ca5c005ffe11b0f50c4fa9016

See more details on using hashes here.

File details

Details for the file py_profiler-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_profiler-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.6

File hashes

Hashes for py_profiler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed0f9e8b14fdab24fcc264ba3fcca26ecdc465d49231046c44112e5e9594eae7
MD5 4d205e1e59c7bb60da7a85fe2c7c5a35
BLAKE2b-256 c1d1deb0d9b6f187a31e2cc45ad616aa05f8e8bd84221309b4cae37dc4f38ab5

See more details on using hashes here.

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