Skip to main content

Python performance tools & utilities

Project description

Python Performance toolt & utilities

License Pypi Python Versions

In a nutshell Python performance tools is a small library with a set of utilities to help you measure and analyze the performance of your code.

Install

> pip install python-performance-tools

Usage examples

Example 1

# File: example_1.py

import os
import time

from performance_tools import *


def main():
    environment = os.environ.get("ENVIRONMENT", None)

    with catch_time("Example message 2", lambda: environment in ("DEVELOPMENT", "STAGING")):
        for i in range(10):
            time.sleep(1)


if __name__ == '__main__':
    main()

After running the code, you will see:

> python examples/example_1.py
Time: 1.021636976 :: Example message

Example 2

# File: example_2.py

import os
import time

from performance_tools import *


def main():
    environment = os.environ.get("ENVIRONMENT", "STAGING")

    with catch_time("Example message 2", lambda: environment in ("DEVELOPMENT", "STAGING")):
        for i in range(10):
            time.sleep(0.1)


if __name__ == '__main__':
    main()

After running the code, you will see:

> export ENVIRONMENT=DEVELOPMENT
> python examples/example_2.py
Time: 1.035312797 :: Example message 2

License

Dictionary Search is Open Source and available under the MIT.

Contributions

Contributions are very welcome. See CONTRIBUTING.md or skim existing tickets to see where you could help out.

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

python-performance-tools-1.0.0.tar.gz (3.4 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