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 Python’s time.perf_counter() on Python 3 and time.clock() on Python 2.
* INSTALLATION *
pytictoc can be installed via conda or pip.
conda: conda install pytictoc -c ecf
pip: pip install pytictoc
* 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytictoc-1.1.1.tar.gz
.
File metadata
- Download URL: pytictoc-1.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b8197cb5b714a08f61d4dff728b5e28bcafdafa5b446c5514dac8a741e3065a |
|
MD5 | 0185611c46768615ee4bb811eebb343b |
|
BLAKE2b-256 | 358126da0f3d04593cd402b49e2680d9924755ae375d00f891328e15ac9bacaa |