-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an example for the new timer module
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |