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
orpip3 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 py_profiler import profiler
@profiler('hello')
def hello():
print('hello')
Access Profiler
- Exec time is in milliseconds
- 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 |
- 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
Project details
Release history Release notifications | RSS feed
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.3.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for py_profiler-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 820f037bf4cb1832a33c19c80add8e092edbf4988dba189cbd0a0b0a03a461ba |
|
MD5 | 143236f3870509822773b4b1910f5799 |
|
BLAKE2b-256 | fc4f4336fbf54972e0ac0119c99d87d295f40bfe627f8f432608ecbdbfc58542 |