Skip to main content

Time That

made-with-python PyPI version PyPI - Downloads PyPI - Implementation pylint status coverage report pipeline status

A human friendly time calculator for functions and code blocks

Install

pip install timethat

Usage

1) You can use it directly for functions

from timethat import TimedFunction
from time import sleep

@TimedFunction()
def suspicious_function():
    time.sleep(1)

if __name__ == '__main__':
    suspicious_function()

results:

TimeThat -> 1.00 sec. -> suspicious_function

TimedFunction optional parameters:

tag: use tag instead of function name

talk: directly echo or echo in results

For example: @TimedFunction(tag="CustomTag", talk:False)

2) Or you can use it in wherever you want

from timethat import TimeThat
from time import sleep

def suspicious_function():
    TimeThat.start("X1")
    for x in range(100):
    	sleep(1)
    	killer_loop = True    
    TimeThat.stop("X1")

if __name__ == '__main__':
    suspicious_function()

results:

TimeThat -> 3.00 sec. -> X1

Stop optional parameters:

talk: echo directly if true else echo later

3) Or you can use it to measure total calculations

from timethat import TimeThat
from time import sleep

def suspicious_function():
    for x in range(3):
        TimeThat.start("X1")
        sleep(0.3)
        killer_loop = True
        TimeThat.stop("X1",talk=False)

    for x in range(3):
        TimeThat.start("X2")
        sleep(1)
        killer_loop = True
        TimeThat.stop("X2",talk=False)

    TimeThat.summary()

if __name__ == '__main__':
    suspicious_function()

results:

TimeThat -> Total: 0.90 sec, Average: 0.30 sec, Count: 3 -> X1

TimeThat -> Total: 3.00 sec, Average: 1.00 sec, Count: 3 -> X2

Summary optional parameters:

tags: echos all timers if None else only echo given timers

reset: resets all timers

4) And you can use logging instead of printout

import timethat
timethat.TALK_TO_LOG = True
# Now it will print out to logging instead of console

Metadata

Release files for timethat 1.1.5

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

Source distribution (sdist)

Source distribution for timethat 1.1.5
File Size Uploaded Provenance Actions
timethat-1.1.5.tar.gz 4.5 kB Without provenance Details for timethat-1.1.5.tar.gz

Release files / timethat-1.1.5.tar.gz

Download URL timethat-1.1.5.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4fd616c5bfdbb533a1d093fbe3256c130ef564d2bca77b4fc1db8f97b54dcf84
BLAKE2b-256 checksum
How to use checksums
62cfa27710ad24874bd94beeaa113ce8a099aa00d01d5a3cbfe70004feabf6b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0

Security for timethat 1.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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