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.3.

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, 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.

0 1 2 3 ....
....
....
.... 9998 9999
[Sat Mar  6 12:41:44 2021 PyExecTime(pyexectime\pyexectime_test.py) <4:6>] -> Execution took 0.000039 seconds

2. Using decorator function py_exec_time

# % API Reference % #

def py_exec_time(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,

0 1 2 3 ....
....
....
.... 9998 9999
[Sat Mar  6 12:41:44 2021 PyExecTime(test.py) <@test_dec:5>] -> Execution took 0.000035 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.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyExecTime-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d690b0c498d61b48e0838ac59c3b79048e7705f5bdb9b3b7fad90e94f5a8d8bb
MD5 b90528919905760d3d5e59f60c065406
BLAKE2b-256 27eb7aa8d3010da0f18b2f8053ee2c61a632e89beefa07ada660bd9b8920c021

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyExecTime-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ddf04ded320e1c8f0ac003e7444ea1879b233d999e15e4e042a27b7477cb5ec3
MD5 1da5050e9e707d69073db42b5bbd0ffc
BLAKE2b-256 603e56e17936b2cfe45fa7dcbf215a9813e319ef264be094c120ce527c410755

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