Skip to main content

A timing package that mimics MATLAB's tic and toc functionality

Project description

Tic Toc

A Python module to make timing in python easier by mimicing MATLAB's tic and toc functions. tic starts a timer by recording the current time, and toc uses the start time to find the elapsed time.

The included func_timer decorator uses tic and toc to give the elapsed time of the wrapped function.

Usage

from tictoc import tic, toc

tic()              # starts the global timer
timer = tic()      # assigns an instance of the Timer class to the timer var without affecting the global timer

toc()              # Prints elapsed time from tic() call
toc(timer)         # Prints elapsed time for the timer given

time = toc(timer)  # Assigns elapsed time to a variable

timer.reset()      # Resets the timer var start time

tic()              # Restarts the global timer

Examples

from time import sleep
from tictoc import tic, toc, func_timer


tic()  # starts global timer
sleep(1)
toc()
sleep(2)
toc()

Elapsed time is 1.00547 seconds.

Elapsed time is 3.00886 seconds.

timer = tic()
sleep(1)
print(f'Timer Assigned to var: {toc(timer)}')
print(f'Global Timer: {toc()}')

Timer Assigned to var: 1.0057699

Global Timer: 4.013537

@func_timer
def func():
    sleep(2)

func()

Elapsed time for function func is 2.00556969 seconds.

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

matlab-tictoc-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

matlab_tictoc-0.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file matlab-tictoc-0.0.1.tar.gz.

File metadata

  • Download URL: matlab-tictoc-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for matlab-tictoc-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6fefe25a46b8bf3a42e41e5a0938e4e2df1578f34120e51625cba6a63dcd7c79
MD5 db0ecf2f1e6aecbc12660f22b660a3bf
BLAKE2b-256 af441592539853ce44e44cb48044437bf5e2904ff0b419ff5944747f8f2555b2

See more details on using hashes here.

File details

Details for the file matlab_tictoc-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for matlab_tictoc-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7094c4180fa499b007e5203496d85be5218504ade5117219cd0c37a8aa451f0c
MD5 6a7a3ace3b484d40450b455c7b2b8173
BLAKE2b-256 306bb20e32b0d4b957d650755b48a3e31d26c5f92ae16c80e3a89e3b5243f1fd

See more details on using hashes here.

Supported by

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