Tic Tec Toc timing for Python
Project description
tictectoc
Tic Tec Toc timing for Python.
How to install
pip install tictectoc
TicTecToc
- TicToc
import time
from tictectoc import TicTecToc
t = TicTecToc()
t.tic()
time.sleep(1)
t.toc() # print '[TTT:default] Elapsed time is 0:00:01'
t.tic()
time.sleep(2)
t.toc() # print '[TTT:default] Elapsed time is 0:00:02'
- TicTecToc
import time
from tictectoc import TicTecToc
t = TicTecToc()
for i in range(10):
t.tic()
time.sleep(1)
t.tec()
t.toc() # print '[TTT:default] Elapsed time is 0:00:10'
- (a) TicTecToc with more than 1 timers
import time
from tictectoc import TicTecToc
t = TicTecToc()
t2 = TicTecToc('timer2')
for i in range(10):
t.tic('timer0')
t.tic('timer1')
t.tic(100)
t2.tic()
time.sleep(1)
t.tec('timer0')
t.tec('timer1')
t.tec(100)
t2.tec()
t.toc('timer0') # print '[TTT:timer0] Elapsed time is 0:00:10'
t.toc('timer1') # print '[TTT:timer1] Elapsed time is 0:00:10'
t.toc(100) # print '[TTT:100] Elapsed time is 0:00:10'
t2.toc() # print '[TTT:timer2] Elapsed time is 0:00:10'
- global instance 'ttt'
import time
from tictectoc import ttt
for i in range(10):
ttt.tic()
time.sleep(1)
ttt.tec()
ttt.toc() # print '[TTT:default] Elapsed time is 0:00:10'
- global function 'tic, tec, toc'
import time
from tictectoc import tic, tec, toc
for i in range(10):
tic()
time.sleep(1)
tec()
toc() # print '[TTT:default] Elapsed time is 0:00:10'
- abbreviation
import time
from tictectoc import TicTecToc
t = TicTecToc()
for i in range(10):
t.i()
time.sleep(1)
t.e()
t.o() # print '[TTT:default] Elapsed time is 0:00:10'
import time
from tictectoc import ttt
for i in range(10):
ttt.i()
time.sleep(1)
ttt.e()
ttt.o() # print '[TTT:default] Elapsed time is 0:00:10'
import time
from tictectoc import i, e, o
for i in range(10):
i()
time.sleep(1)
e()
o() # print '[TTT:default] Elapsed time is 0:00:10'
- decorator
import time
from tictectoc import ttt
@ttt.dec('timer0')
def function(n=10):
for i in range(n):
time.sleep(1)
function() # print '[TTT:timer0] Elapsed time is 0:00:10'
import time
from tictectoc import dec
@dec('timer0')
def function(n=1):
for i in range(n):
time.sleep(1)
function() # print '[TTT:timer0] Elapsed time is 0:00:10'
- (a) with statement
import time
from tictectoc import TicTecToc
with TicTecToc():
for i in range(10):
time.sleep(1)
# print '[TTT::default] Elapsed time is 0:00:10'
import time
from tictectoc import ttt
with ttt:
for i in range(10):
time.sleep(1)
# print '[TTT::default] Elapsed time is 0:00:10'
- (b) double with
import time
from tictectoc import TicTecToc
with TicTecToc('timer0'):
with TicTecToc('timer1'):
time.sleep(10)
time.sleep(10)
# print '[TTT::timer1] Elapsed time is 0:00:10'
# print '[TTT::timer0] Elapsed time is 0:00:20'
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for tictectoc-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3443de3867e0c4cc866f38381cd48c0a4d3d401009330f665c53a4c22b006e23 |
|
MD5 | 03760bd81879f4a28f6badf98e4b7b07 |
|
BLAKE2b-256 | 984ee7a0cb64142c242a5b4c75b1548b3f3276b199abebbd271e318832375b00 |