Created
June 15, 2017 03:35
-
-
Save tanmayb123/68b06dc781f464082c825b419db2f627 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
import multiprocessing | |
import random | |
import sys | |
rangemin = 1 | |
rangemax = 9 | |
def randomGen(num): | |
values = [] | |
for i in range(0, num): | |
values.append(random.randint(rangemin, rangemax)) | |
return values | |
def randomGenPar_backend(backinput): | |
return random.randint(rangemin, rangemax) | |
def randomGenPar(num): | |
pool = multiprocessing.Pool() | |
return pool.map(randomGenPar_backend, range(0, num)) | |
randNum = int(sys.argv[1]) | |
# NON-PARALLEL - USE FOR 1 CORE | |
# random.seed(999) | |
# randomGen(randNum) | |
# PARALLEL - USE FOR OPTIMAL PROCESSES | |
# random.seed(999) | |
# randomGenPar(randNum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment