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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tictac_timer-0.1.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

tictac_timer-0.1.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file tictac_timer-0.1.1.tar.gz.

File metadata

  • Download URL: tictac_timer-0.1.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tictac_timer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 94ae0d1fe9ba053148db993e11dfeae3d5bd5655bf14d7c3e6e2bf4409ee8e32
MD5 afb38230d5078487f2a6591d96d485af
BLAKE2b-256 e90dc5b0ca5a73c9aee09e0cb2830ebe1ff3d982cd74d4ac40c3e57a969a1594

See more details on using hashes here.

File details

Details for the file tictac_timer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tictac_timer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for tictac_timer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1aadf9b9312b041dea168fe507a38b680b1b52e8d67b3796c83023434981f39
MD5 b0ba9640873a5f6979c430edbdcb9f7e
BLAKE2b-256 6315cd406d70d35b6f03e6359d9fa02ca0a28712640d49bad7d47094d3555721

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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