Skip to main content

WSGI middleware for line-by-line profiling

Project description

wsgi_lineprof is a WSGI middleware for line-by-line profiling.

Please note that this project is under development, so you may see many API imcompatible changes.

At a Glance

You can use wsgi_lineprof as a WSGI middleware of existing applications.

$ pip install wsgi_lineprof

Example usage with Bottle:

import time

import bottle
from wsgi_lineprof.middleware import LineProfilerMiddleware

app = bottle.default_app()


@app.route('/')
def index():
    time.sleep(1)
    return "Hello world!!"

if __name__ == "__main__":
    # Add wsgi_lineprof as a WSGI middleware!
    app = LineProfilerMiddleware(app)
    bottle.run(app=app)

Run the above script to start web server, then access http://127.0.0.1:8080.

You can see the results of profiling functions like this:

File: ./app.py
Name: index
Total time: 1.00518 [sec]
  Line      Hits         Time  Code
===================================
     9                         @app.route('/')
    10                         def index():
    11         1      1005175      time.sleep(1)
    12         1            4      return "Hello world!!"

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

wsgi_lineprof-0.1.1.tar.gz (30.4 kB view details)

Uploaded Source

File details

Details for the file wsgi_lineprof-0.1.1.tar.gz.

File metadata

File hashes

Hashes for wsgi_lineprof-0.1.1.tar.gz
Algorithm Hash digest
SHA256 336a6a69f81d396fd8c8ec90f6b186bf9fd01279df01a93bdd8db1d8b6228a1f
MD5 322d855a79282b9b83fc5c0fdd9de04a
BLAKE2b-256 d32b4d415b803a2687e797de2496f5f8fecb4b506275b4e446f7cc627783d8fa

See more details on using hashes here.

Provenance

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