Skip to main content

PyExecTime is a python module which can be used to find the execution time of a complete or partial python code.

Project description

PyExecTime

PyExecTime is a python module which can be used to find the execution time of a complete or partial python code.

Version

The current version of this module is 0.0.2.

Check it by below command,

python -m pyexectime.version

Installation

You can use pip to install the module or you clone the repository from github and install it manually.

pip install pyexectime

or

git clone https://github.com/antaripchatterjee/PyExecTime.git
cd PyExecTime
python setup.py install

Usage and Application

You can use the module in two different ways.

1. Using contextlib manager PyExecTime

# % API Reference % #

class PyExecTime():
    def __init__(self, text="Execution took %lf seconds", file=sys.stdout):
        ...

    def __exit__(self, exc_type, exc_val, exc_tb):
        ...

    def __enter__(self):
        ...

Follow the below code to understand the usage of the contextlib manager class PyExecTime.

from pyexectime.inspector import PyExecTime

with PyExecTime():
    for i in range(10000):
        print(i, end = ' ')

The above code will generate the below output.

1 2 3 4 ....
....
....
.... 998 990
PyExecTime [(main.py) 3:5] -> Execution took 0.000417 seconds

2. Using decorator function py_exec_time

# % API Reference % #

def py_exec_time(text="Execution took %lf seconds", file=sys.stdout):
    def wrapper(fn):
        @wraps(fn)
        def inner(*argv, **kwargv):
            ...
        return inner
    return wrapper

The same objective can be done using a following code

from pyexectime.inspector import py_exec_time

@py_exec_time()
def write_number(r):
    for i in range(r):
        print(i, end = ' ')

write_number(10000)

And the output will be,

1 2 3 4 ....
....
....
.... 998 990
PyExecTime [(main.py) 8:8] -> Execution took 0.000397 seconds

License

The module has been licensed under MIT license.

Development

Currently this python module is in BETA stage but it can be used safely.

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

PyExecTime-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

PyExecTime-0.0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file PyExecTime-0.0.2.tar.gz.

File metadata

  • Download URL: PyExecTime-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for PyExecTime-0.0.2.tar.gz
Algorithm Hash digest
SHA256 64a8c36c9c397acbc75e91fe8ed27aac5ed320e5175080dbd04fbe4d261776fc
MD5 540a179cd73d6f9e9260b982a4bd5d73
BLAKE2b-256 6ac96bd0dd233825a6e9c2cd0fe736dd6f4814d4c165620e0772b2eb7e4658a1

See more details on using hashes here.

File details

Details for the file PyExecTime-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: PyExecTime-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for PyExecTime-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9346217ca6e7aa2ea1d798afa18c026e19bcd0be9e6d6293eae6f2011b4247f
MD5 93e55753034d67d2bfc2ab932bd6ed1c
BLAKE2b-256 b444f91d6a388d7f683da053a0f46fb75a1c12df72deb40fdc46624d0acddfcc

See more details on using hashes here.

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