Created
July 29, 2011 21:41
-
-
Save b1naryth1ef/1114801 to your computer and use it in GitHub Desktop.
Multicore random number generator
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
from multiprocessing import Process, Queue | |
import random | |
seed = "123456789" | |
#10,000,000 | |
county = 10000000 | |
count = county/8 | |
print count | |
def generate(seed2, count, filey): | |
f = open("./random-"+str(filey)+".txt", "w") | |
x = 0 | |
while x < count: | |
rand = random.random() | |
rand2 = random.randint(1,999) | |
seed = int(seed2) | |
t1 = seed + rand | |
t2 = seed / 100 | |
t3 = t1 + t2 * rand2 | |
t4 = str(round(t3)) | |
t5 = t4.replace('.0', '') | |
f.write(str(t5)) | |
x += 1 | |
f.close | |
def funcy(q,f): generate(seed, count, f) | |
def main(): | |
q = Queue() | |
for i in range(1,9): | |
Process(target=funcy, args=(q,'filey%s' % (str(i)))).start() | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment