Skip to main content

⏱️ tictac

Python 3.8+ License MIT Status

tictac - a simple timer for your code

(─‿‿─)

   __  _      __            
  / /_(_)____/ /_____ ______
 / __/ / ___/ __/ __ `/ ___/
/ /_/ / /__/ /_/ /_/ / /__  
\__/_/\___/\__/\__,_/\___/  
                            

installation

pip install tictac-timer

quick start

from tictac import timer
import time

# context manager
with timer("data loading"):
    time.sleep(1.2)
    # [tictac] data loading: 1.20 sec

# decorator
@timer
def heavy_process():
    time.sleep(0.5)
    # [tictac] heavy_process: 0.50 sec

# decorator with parameters
@timer("processing", unit="ms")
def fast_process():
    time.sleep(0.01)
    # [tictac] processing: 10.00 ms

parameters

timer(name=None, unit="s", output=None)
  • name — timer label (defaults to function name)
  • unit — time unit: "s", "ms", "min"
  • output — callback (msg: str) -> None (defaults to print)

examples

custom output

import logging

log = logging.getLogger(__name__)

with timer("query", output=log.info):
    db.execute("SELECT ...")

multiple timers

with timer("preparation"):
    time.sleep(0.3)

with timer("processing", unit="ms"):
    time.sleep(15)

# [tictac] preparation: 0.30 sec
# [tictac] processing: 15.00 ms

license

AGPL-3.0

Metadata

Release files for tictac-timer 0.1.1

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

Source distribution (sdist)

Source distribution for tictac-timer 0.1.1
File Size Uploaded
tictac_timer-0.1.1.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tictac-timer 0.1.1
File Interpreter ABI Platform
tictac_timer-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / tictac_timer-0.1.1.tar.gz

Download URL tictac_timer-0.1.1.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
94ae0d1fe9ba053148db993e11dfeae3d5bd5655bf14d7c3e6e2bf4409ee8e32
BLAKE2b-256 checksum
How to use checksums
e90dc5b0ca5a73c9aee09e0cb2830ebe1ff3d982cd74d4ac40c3e57a969a1594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / tictac_timer-0.1.1-py3-none-any.whl

Download URL tictac_timer-0.1.1-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1aadf9b9312b041dea168fe507a38b680b1b52e8d67b3796c83023434981f39
BLAKE2b-256 checksum
How to use checksums
6315cd406d70d35b6f03e6359d9fa02ca0a28712640d49bad7d47094d3555721
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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