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

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(main.py) <3:5>] -> 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(main.py) <@write_number:8>] -> 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.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyExecTime-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 0777c29e585c353ef96081c3c0e123852ee449dee5ac3ce699d00b4b256e7fbe
MD5 161cb54d8dfb9f2f00557be8eafce0df
BLAKE2b-256 8c2a0c620989544496c587933119de7e2410471198c68bad834d443033dc0f56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyExecTime-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e38811a03eb1ca267d8c30852a8c8d3ad91b4d523771de1f35238e4494ff1a62
MD5 5e2092649fa5bdcde3e4f3c4d8f88d00
BLAKE2b-256 8a4c5a860720c2d06cf939199138d93593d6a0b56f5d959ca8fe7a6b5264c44b

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