Skip to main content

Time code using syntax similar to tic and toc in MATLAB

Project description

pytictoc contains a class TicToc which replicates the functionality of MATLAB’s tic and toc for easily timing sections of code. Under the hood, pytictoc uses the default_timer function from Python’s timeit module.

INSTALLATION

pytictoc can be installed and updated via conda or pip.

pip

pip install pytictoc
pip install pytictoc --upgrade

conda

conda install pytictoc -c ecf
conda update pytictoc -c ecf

USAGE

>> from pytictoc import TicToc

>> t = TicToc() #create instance of class

>> t.tic() #Start timer
>> t.toc() #Time elapsed since t.tic()
Elapsed time is 2.612231 seconds.

>> t.toc('It has been') #alternative message
It has been 16.494467 seconds.

>> t.toc(restart=True) #restart timer after reporting time
Elapsed time is 36.986837 seconds.
>>t.toc()
Elapsed time is 2.393425 seconds.

>>spam = t.tocvalue() #return elapsed time instead of printing
>>spam
20.156261717544602

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

pytictoc-1.3.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pytictoc-1.3.0-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytictoc-1.3.0.tar.gz.

File metadata

  • Download URL: pytictoc-1.3.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytictoc-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5c29e8d9a79346afc5c8aea2d658b23c94e9bd01df578991a32163b0c39aae25
MD5 fa274447deab44229a3e8362fab68c6f
BLAKE2b-256 d6df0f61df4ecfbfe2de1cd9f2482e657f4f16270f208c8869857c0842b6d3ee

See more details on using hashes here.

File details

Details for the file pytictoc-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytictoc-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 43474d44f70cddc6cf162a4fa14abe52ced2d88bf6fbddb35186a3a90a3a8da7
MD5 c00f830cf49ace02401a6aa5d836c2c9
BLAKE2b-256 17f333ac6206985ecc4e5d79201958fe5b71ac39bc2406553b7d43af741d8cce

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