-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor doc improvements. One more demo/test.
- Loading branch information
Leo Dirac
committed
Oct 23, 2019
1 parent
0af4e1b
commit 38752f3
Showing
4 changed files
with
52 additions
and
17 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
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 |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import random | ||
import time | ||
from timebudget import timebudget | ||
|
||
# More or less what's in the README for loops | ||
# but 10x faster so we can test it 100x and get the averages about right. | ||
|
||
@timebudget | ||
def possibly_slow(): | ||
print('slow', end=' ', flush=True) | ||
time.sleep(0.06) | ||
time.sleep(0.03) | ||
|
||
def sometimes(): | ||
return random.random() < 0.6 | ||
|
||
@timebudget | ||
def should_be_fast(): | ||
print('quick', end=' ', flush=True) | ||
time.sleep(0.03) | ||
time.sleep(0.003) | ||
|
||
@timebudget | ||
def outer_loop(): | ||
possibly_slow() | ||
possibly_slow() | ||
if sometimes(): | ||
possibly_slow() | ||
should_be_fast() | ||
should_be_fast() | ||
possibly_slow() | ||
time.sleep(0.2) | ||
print("dance!") | ||
|
||
for n in range(7): | ||
for n in range(100): | ||
outer_loop() | ||
|
||
timebudget.report('outer_loop') |
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,27 @@ | ||
import time | ||
from timebudget import timebudget | ||
|
||
@timebudget | ||
def possibly_slow(): | ||
print('slow', end=' ', flush=True) | ||
time.sleep(0.06) | ||
|
||
@timebudget | ||
def should_be_fast(): | ||
print('quick', end=' ', flush=True) | ||
time.sleep(0.03) | ||
|
||
@timebudget | ||
def outer_loop(): | ||
possibly_slow() | ||
possibly_slow() | ||
should_be_fast() | ||
should_be_fast() | ||
possibly_slow() | ||
time.sleep(0.2) | ||
print("dance!") | ||
|
||
for n in range(7): | ||
outer_loop() | ||
|
||
timebudget.report('outer_loop') |
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 |
---|---|---|
|
@@ -11,3 +11,6 @@ def test_demo2(): | |
|
||
def test_demo3(): | ||
import demo3 | ||
|
||
def test_demo4(): | ||
import demo4 |