-
-
Save andrewsmedina/5771162 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
"Logistic map iteration timing" | |
from itertools import islice | |
import time | |
import main | |
def logistic_map(r, x): | |
assert r > 0, 'R must be a positive number' | |
assert 0 < x < 1, 'X must be a number between 0 and 1' | |
while True: | |
x = r * x * (1 - x) | |
yield x | |
if main.executed(): | |
times = [] | |
minimum = Ellipsis | |
maximum = None | |
iterator = logistic_map(3.65, 0.01) | |
for loop in xrange(15): | |
start = time.clock() | |
for x in islice(iterator, 500): | |
minimum = min(minimum, x) | |
maximum = max(maximum, x) | |
stop = time.clock() | |
times.append(stop - start) | |
print "Iteration times" | |
print ",".join(str(i) for i in times) | |
print "X range" | |
print minimum, maximum |
This file contains hidden or 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
[aliles@macbookpro ~]$ pypy chaos.py | |
Iteration times | |
0.001396,0.001507,0.014415,0.000177,0.000169,0.000174,0.000168,0.000168,0.000211,0.000182,0.000169,0.000172,0.000175,0.000168,0.000169 | |
X range | |
0.036135 0.912499995154 | |
[aliles@macbookpro ~]$ python2.7 chaos.py | |
Iteration times | |
0.000584,0.000558,0.000558,0.000556,0.000564,0.000559,0.000555,0.000556,0.000558,0.000556,0.000557,0.000569,0.000556,0.000561,0.000558 | |
X range | |
0.036135 0.912499995154 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment