Giter Club home page Giter Club logo

gevent-profiler's Introduction

gevent-profiler

This module provides a simple way to get detailed profiling information about a Python process that uses the gevent library. The normal Python profilers are not nearly as useful in this context, due to gevent's greenlet threading model.

Installation

$ sudo python setup.py install

Usage

To generate profiling information for a single function call:

from gevent import monkey
monkey.patch_all()
import gevent_profiler

def my_func(a, b, c):
    print a, b, c

gevent_profiler.profile(my_func, 1, 2, c=3)

To generate profiling information for an arbitrary section of code:

from gevent import monkey
monkey.patch_all()
import gevent_profiler

gevent_profiler.attach()
for x in range(42):
    print pow(x, 2)
gevent_profiler.detach()

To start generating profiling information when a specific signal is received, and to stop after a set amount of time has elapsed:

from gevent import monkey
monkey.patch_all()
import gevent_profiler

gevent_profiler.attach_on_signal(signum=signal.SIGUSR1, duration=60)

x = 2
while True:
    print pow(x, 50000)

To profile a Python app from the command line:

$ python gevent_profiler/__init__.py --help
$ python gevent_profiler/__init__.py my_app.py

Options

Set the filename for the stats file. Defaults to sys.stdout. May be set to None to disable.

gevent_profiler.set_stats_output('my-stats.txt')

Set the filename for the summary file. Defaults to sys.stdout. May be set to None to disable.

gevent_profiler.set_summary_output('my-summary.txt')

Set the filename for the trace file. Defaults to sys.stdout. May be set to None to disable.

gevent_profiler.set_trace_output('my-trace.txt')

Print runtime statistics as percentages of total runtime rather than absolute measurements in seconds:

gevent_profiler.print_percentages(True)

Count time blocking on IO towards the execution totals for each function:

gevent_profiler.time_blocking(True)

gevent-profiler's People

Contributors

srlindsay avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.