Created
August 4, 2010 05:29
-
-
Save dgleich/507698 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import sys | |
import array | |
import itertools | |
import random | |
def test(memsize): | |
print "allocating" | |
a = array.array('d') | |
a.extend(itertools.repeat(0,memsize/8)) | |
print "starting iteration" | |
iter = 1 | |
while 1: | |
random.seed() | |
state = random.getstate() | |
for i in xrange(0,len(a)): | |
a[i] = random.random() | |
random.setstate(state) | |
for i in xrange(0,len(a)): | |
rand = random.random() | |
if a[i] != rand: | |
print "error %6i:%10i %g is not %g"%(iter, i, a[i], rand) | |
print "finished iteration %i"%(iter) | |
iter += 1 | |
def main(): | |
test(int(sys.argv[1])) | |
#test(1050000) | |
if __name__=='__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment