Skip to content

Commit

Permalink
Added an example for the new timer module
Browse files Browse the repository at this point in the history
  • Loading branch information
YHordijk committed May 7, 2024
1 parent 8e94415 commit dbefeee
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/timer_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tcutility.timer import timer
from time import sleep
import numpy as np


@timer
def test():
with timer('test.loop.loop.loop.outer'):
for _ in range(5):
with timer('test.loop.loop.inner'):
sleep(.041 + (np.random.rand() - .5)/30)

@timer
def test2():
sleep(.231 + (np.random.rand() - .5)/7)

[test() for _ in range(3)]
[test2() for _ in range(5)]

for i in range(10):
with timer('loop'):
sleep(i/1000)

0 comments on commit dbefeee

Please sign in to comment.