Fast, simple and accurate Python timing. Written in Rust.
Find a file
2023-12-19 16:18:43 +00:00
.docs [24/11/23] Updating logo 2023-11-24 16:20:18 +00:00
.github/workflows [24/11/23] Fixing workflow file 2023-11-24 17:44:09 +00:00
src [19/11/23] Adding tests and exception for bad syntax 2023-11-19 21:20:09 +00:00
tests [18/11/23] Initial Python tests commit 2023-11-18 21:20:45 +00:00
.gitignore [20/11/23] GitHub Actions testing workflow 2023-11-20 10:42:23 +00:00
Cargo.lock [05/11/23] Initial commit 2023-11-05 12:13:16 +00:00
Cargo.toml [05/11/23] Initial commit 2023-11-05 12:13:16 +00:00
pyproject.toml [05/11/23] Initial commit 2023-11-05 12:13:16 +00:00
README.md [19/12/23] Updating PyPi project name 2023-12-19 16:12:43 +00:00
requirements.txt [19/11/23] Adding tests and exception for bad syntax 2023-11-19 21:20:09 +00:00
run.py [15/11/23] Updating README, adding simple run script 2023-11-15 11:19:13 +00:00

A logo with the word tictoc followed by a stopwatch emoji A logo with the word tictoc followed by a stopwatch emoji

Fast, simple and accurate Python timing. Written in Rust.

badge badge

Installation

Install with pip.

$ python -m pip install tictoc

Usage

Import and initialise. The module must be initialised to be used!

import tictoc
t = tictoc.init()

Begin timing with tic(), and stop with toc().

t.tic()
# some code
t.toc()

When toc is called, the results are saved. They can be accessed with the following syntax:

t.results.{unit}

The available units are:

t.results.nanos   # u128
t.results.micros  # u128
t.results.millis  # u128
t.results.seconds # f64

Full example

import time

import tictoc
t = tictoc.init()

t.tic()       # start timing
time.sleep(3) # sleep for 3 seconds
t.toc()       # stop timing

print(t.results.seconds)
# >>> 3.000457715