ericcfields / pytictoc

MATLAB style tic and toc timing for Python
Other
7 stars 2 forks source link

Add restart parameter to tic #1

Open htarnacki opened 3 years ago

htarnacki commented 3 years ago

hi, i propose small improvement:

instead of:

>> t.tic()
>> t.toc(restart=True)
Elapsed time is 36.986837 seconds.
>>t.toc(restart=True)
Elapsed time is 2.393425 seconds
>>t.toc(restart=True)
Elapsed time is 2.393425 seconds
>>t.toc(restart=True)
Elapsed time is 2.393425 seconds
...

it would be great to have such an option:

t.tic(restart=True)
>> t.toc()
Elapsed time is 36.986837 seconds.
>>t.toc()
Elapsed time is 2.393425 seconds
>>t.toc()
Elapsed time is 2.393425 seconds
>>t.toc(restart=False)
Elapsed time is 2.393425 seconds

or

t.tic(restart=True)
>> t.toc()
Elapsed time is 36.986837 seconds.
>>t.toc()
Elapsed time is 2.393425 seconds
>>t.toc()
Elapsed time is 2.393425 seconds
t.finaltoc()
Elapsed time is 2.393425 seconds

or

t.tic()
>> t.rtoc()
Elapsed time is 36.986837 seconds.
>>t.rtoc()
Elapsed time is 2.393425 seconds
>>t.rtoc()
Elapsed time is 2.393425 seconds
>>t.toc()
Elapsed time is 2.393425 seconds

where "rtoc" means "restartable toc"

chrimaho commented 2 years ago

Hi @htarnacki , I have now implemented both these suggestions. Both the restart parameter within the .tick() method, and the .rtock() method. Plus a few other goodies to make it a whole lot better. Please check: py-tictoc-timer on GitHub and PyPI. Cheers, Chris M