Skip to main content

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.

Metadata

Release files for ez-timer 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ez-timer 0.0.2
File Size Uploaded
ez-timer-0.0.2.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ez-timer 0.0.2
File Interpreter ABI Platform
ez_timer-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.4 kB

Release files / ez-timer-0.0.2.tar.gz

Download URL ez-timer-0.0.2.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
528debbe3e59a369f6eb755bc96f8be54b59b34e00da87b4502b2aecff146542
BLAKE2b-256 checksum
How to use checksums
57be029be6d0f3200b39b2e54ed15ca75c95ae3e8d97bb8fc34605de644de0da
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / ez_timer-0.0.2-py3-none-any.whl

Download URL ez_timer-0.0.2-py3-none-any.whl
Size 2.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c9456423266a1276e4a037096fc6345f5b69b6e941e0230e0e6e79bab598c02
BLAKE2b-256 checksum
How to use checksums
62c55e745951f7d31e3b10140f989587ed98d5792eefb75f241abc13643b50e9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page