Skip to main content

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

Project description

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

PyPI Downloads PyPI Downloads

Installation

Install with pip.

$ python -m pip install tictoc

Usage

Import.

from tictoc import tic,toc

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

tic()
# some code
toc()

A call to tic() can be followed with multiple toc() calls. Each will print the time elapsed since the most recent tic() call.

tic()
time.sleep(3)
toc()
# >>> The elapsed time was 3.000132333 seconds.
time.sleep(3)
toc()
# >>> The elapsed time was 6.000383124 seconds.

For more complex timing operations, you can assign the output of tic() and pass it as an input to toc().

[!NOTE] This syntax cannot be used interchangeably with the default syntax above. Any call to tic() resets the global timer.

firstTic = tic()
time.sleep(3)
secondTic = tic()
time.sleep(1)
toc(firstTic)
# >>> The elapsed time was 4.000317251 seconds.
time.sleep(3)
toc(secondTic)
# >>> The elapsed time was 4.000312568 seconds.

Any call to toc() will print the elapsed time in seconds. You can save the results with full precision by assigning the output of toc().

tic()
# some code
results = toc()

The available units are:

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

Full example

import time
from tictoc import tic,toc

tic()         # start timing
time.sleep(3) # sleep for 3 seconds
toc()         # stop timing
# >>> The elapsed time was 3.000132333 seconds.

firstTic = tic()
time.sleep(3)
secondTic = tic()
time.sleep(1)
toc(firstTic)
# >>> The elapsed time was 4.000317251 seconds.
time.sleep(3)
toc(secondTic)
# >>> The elapsed time was 4.000312568 seconds.

tic()
results = toc()
print(results.nanos)
# >>> 2825

Project details


Download files

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

Source Distribution

tictoc-0.2.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distributions

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

tictoc-0.2.1-pp311-pypy311_pp73-win_amd64.whl (136.5 kB view details)

Uploaded PyPyWindows x86-64

tictoc-0.2.1-cp314-cp314t-win_arm64.whl (130.5 kB view details)

Uploaded CPython 3.14tWindows ARM64

tictoc-0.2.1-cp314-cp314t-win_amd64.whl (136.0 kB view details)

Uploaded CPython 3.14tWindows x86-64

tictoc-0.2.1-cp313-cp313t-win_arm64.whl (130.4 kB view details)

Uploaded CPython 3.13tWindows ARM64

tictoc-0.2.1-cp313-cp313t-win_amd64.whl (135.9 kB view details)

Uploaded CPython 3.13tWindows x86-64

tictoc-0.2.1-cp38-abi3-win_arm64.whl (136.0 kB view details)

Uploaded CPython 3.8+Windows ARM64

tictoc-0.2.1-cp38-abi3-win_amd64.whl (141.3 kB view details)

Uploaded CPython 3.8+Windows x86-64

tictoc-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl (255.7 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

tictoc-0.2.1-cp38-abi3-musllinux_1_2_i686.whl (277.2 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ i686

tictoc-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl (245.4 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

tictoc-0.2.1-cp38-abi3-manylinux_2_34_i686.whl (284.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ i686

tictoc-0.2.1-cp38-abi3-manylinux_2_31_x86_64.whl (257.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.31+ x86-64

tictoc-0.2.1-cp38-abi3-manylinux_2_31_aarch64.whl (246.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.31+ ARM64

tictoc-0.2.1-cp38-abi3-macosx_11_0_arm64.whl (701.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tictoc-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl (710.0 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file tictoc-0.2.1.tar.gz.

File metadata

  • Download URL: tictoc-0.2.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a352a8e8cf887974a8afb3cc5f7d2351924a46ba5e5c92a739ce402c1d3b255a
MD5 02c4c2d7648095d07206670808741d13
BLAKE2b-256 eab28cefd5b04000883279743e4ebe89093603e1c3a7a523b6c7cb8f9c90758f

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 0f52d7f1c013624f5e1c599161cb2c7588ecc036b586405596b073539f0b0407
MD5 0c0f75682f13c35714ab7f58a7ba9b34
BLAKE2b-256 a445e8df73e18abb46eb8f313900f1dc4bd5b7874963c7ddf7c900b1e2970bec

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp314-cp314t-win_arm64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp314-cp314t-win_arm64.whl
  • Upload date:
  • Size: 130.5 kB
  • Tags: CPython 3.14t, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 0914979c5b6ee5f899354c02d613213d961a5a1545172d20a64dc2f00f3ecad8
MD5 5dada4b8910e8bd129d2e005576bcf0e
BLAKE2b-256 7f43c14dbc63bc0228ad03e8bb0c56a70f7b80d69e4a58bb84749259251db55a

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 136.0 kB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 839ff48988d9e4bb99ccd3ec88f6bb3fcd9277122f39bfd37ff57954022ecdca
MD5 cb5ee1f4d3bf42599661bbdf0bda7690
BLAKE2b-256 6460efb939030eda10f7e43a1b1fbb03aa0ccf0383804ce8d62ee93ceaf09ab9

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp313-cp313t-win_arm64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp313-cp313t-win_arm64.whl
  • Upload date:
  • Size: 130.4 kB
  • Tags: CPython 3.13t, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp313-cp313t-win_arm64.whl
Algorithm Hash digest
SHA256 8675ddcbc7e27a93cc12c4db1c20f309260f4c4f9198ae7272b270869e20b85b
MD5 9e163552ba67cb0e584253624a8393e4
BLAKE2b-256 0c97645470c282cbd9b757b6596b4b06c2c9d2ac4163223ca3f6de62a60f0725

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 135.9 kB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 48af04b39480e822a5255e133c494ed69713c8c75806e408dfaae9f7603e5832
MD5 e72926dfb160439cf321c5b8d469e051
BLAKE2b-256 1d8e23d0bb9ed2790d463aa23b2283e3b538ea337529bdde812e597a131c79fa

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp38-abi3-win_arm64.whl
  • Upload date:
  • Size: 136.0 kB
  • Tags: CPython 3.8+, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 26522eb57c38a47f24d54d1bac5d52647506d0e8fb6fce5e19c05866725ad489
MD5 acab516e63ecaeb353c150b3e18548bb
BLAKE2b-256 ad439eea34a2a856b2c083995cd75a421148dba6c0307742e2399efbe757d985

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 141.3 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7b3572dcf89ce67ab7626e4fe526102fd9b925ff0bd7a088b0e460259998e86d
MD5 d76fe2c1909d828fa00988a7d199fc73
BLAKE2b-256 a479ae7b53893017f8c7af574f43f6917113cdbfd3fc625b747ac3777312442c

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 673d34c4eaa803640df8a15db6b8ecbe2b7fb242a5aede0790c75fca4b07b857
MD5 52458f9b9cd1248fc02de88848cb77dd
BLAKE2b-256 c90c80ea525e2b3caac83e9aebdf8d734c2799ef6f04fbb7ea7d4ad7b1be4fa7

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-musllinux_1_2_i686.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp38-abi3-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 277.2 kB
  • Tags: CPython 3.8+, musllinux: musl 1.2+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 1209179945a4b487ff1a21d49ad67775036c45012d1be72edddfe5a6327f1aca
MD5 d37401444ab19549532429628a6afdf2
BLAKE2b-256 744e5c83ba796b3f0908f2c553736bf64798bae9587679a94316045a126cb4bf

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1997ba5a88a3a794f78aceeacf2ec014296d6ba7c536086d7fc825d9cbaa4700
MD5 297ae78e20f6cdd80ebec52369f5a22b
BLAKE2b-256 20dfe47100b41c84d2905d601c51de039f1772b601efb15b0f36c64b24b9f1a0

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-manylinux_2_34_i686.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp38-abi3-manylinux_2_34_i686.whl
  • Upload date:
  • Size: 284.5 kB
  • Tags: CPython 3.8+, manylinux: glibc 2.34+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-manylinux_2_34_i686.whl
Algorithm Hash digest
SHA256 e0cab3b3f57e744828460eee82aa54b29871e95543c19a67f2480ef91c6b5770
MD5 0efae6e30e1dd6d8085e0d18b16232b9
BLAKE2b-256 edea842ac88a6e3c9cf0da6eb036401713bf05c017486076cea65ee787a5db06

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 2093f1025438843677da158b24d7c0be67c40db5f7bbc880a88bb761bdf308ca
MD5 8f298ddc8176f7416321d348a17462a9
BLAKE2b-256 8c2c4f59656c875269a2338df9b9ae3a3d04c51630684de71c3cea2f2e68ad26

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 e4c19218aec01dad9946a27d670172b474d8c740f2f8fd1b021b40ca904f576f
MD5 377ddd73f9a34e20eea331d8720cbb43
BLAKE2b-256 e15daaf6eabbdd7f54efbde0e43a54d66cf4647dacd46a116834bf560df201d9

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tictoc-0.2.1-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 701.8 kB
  • Tags: CPython 3.8+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0rc2

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1289905e4bf10e54d35a312ba9bcbc5cd665383ddcf23c0465666e6d174a4426
MD5 459515ee5685488d976b8c6d05d14f01
BLAKE2b-256 e372bdde28672a8b938b74200d50aece5b4916d471dc4bf9209ca08f60017677

See more details on using hashes here.

File details

Details for the file tictoc-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tictoc-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ee65aa57c06a22f3156dcf615d0d9a905b846b6bd19fee2148b365ab10773708
MD5 6176f2a4d8f84ce90f50ba84d51759e1
BLAKE2b-256 a307606b2d0e64caadb5fef560f57ddd1325450e4aea51ec22e16f44f35efc52

See more details on using hashes here.

Supported by

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