Skip to main content

The simplest way to time a block of code.

Project description

ez-timer

The easiest way to time a code block in Python.

Quick Links:

Overview

ez-timer provides a single, easy to use API for timing function calls.

with ez_timer() as timer:
    1 + 1
timer.result
# 0.000001

That is it. That is the API. Solves one problem, and solves it well.

Background

When working on extensive profiling for an enterprise Python project I regularly found myself writing:

start = time.time()
# some code
end = time.time()

result = end - start
# do something with result

While timeit exists, I found timeit to be heavy handed for what I needed in 90% of cases. This inspired me to create ez-timer.

Installation

ez-timer can be installed from pypi:

pip install ez-timer

Usage

Using ez-timer is simple:

from ez_timer import ez_timer

with ez_timer() as timer:
  # run expensive computation
  time.sleep(1)

print(timer.result)
# > 1.0001

That's all. That is the API.

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

ez-timer-0.0.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ez_timer-0.0.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file ez-timer-0.0.2.tar.gz.

File metadata

  • Download URL: ez-timer-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.62.0 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for ez-timer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 528debbe3e59a369f6eb755bc96f8be54b59b34e00da87b4502b2aecff146542
MD5 db755a441b79411e2f27973beb857cd8
BLAKE2b-256 57be029be6d0f3200b39b2e54ed15ca75c95ae3e8d97bb8fc34605de644de0da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ez_timer-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.62.0 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for ez_timer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9c9456423266a1276e4a037096fc6345f5b69b6e941e0230e0e6e79bab598c02
MD5 380a94ae2b25b51bc1f5573f248933a9
BLAKE2b-256 62c55e745951f7d31e3b10140f989587ed98d5792eefb75f241abc13643b50e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page