Skip to main content

Lightweight profiling tool to detect performance BottleNecks in Python code.

Project description

Hence the name: bn - BottleNeck. And you know keys B and N are very comfortable to type quickly in a row.

Usage:

bn('iteration')

for item in generator:

    bn('step 1')
    # code of step 1

    bn('step 2')
    # code of step 2

    bn('iteration')

bn() # Stop tracking.

if bn.total > 1.0:
    logging.info(bn)

Result:

22.2632    TOTAL
20.6403    step 2
 1.6209    step 1
 0.0020    iteration

Scope:

pip install bn
from bn import bn

# OR:

from bn import Bn
def action():
    bn = Bn()

Config:

bn.total_key = 'TOTAL'
bn.format = '{seconds:>10.4f}    {key}'

See also: bn.py:test().

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

bn-0.1.4.tar.gz (1.9 kB view hashes)

Uploaded Source

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