Created
November 22, 2015 13:51
-
-
Save itsPG/96512553c6ed3592daa8 to your computer and use it in GitHub Desktop.
python benchmark
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 sys, itertools | |
from multiprocessing import Pool | |
def do_permutations(string): | |
for i in itertools.permutations(string): | |
pass | |
return 'Done count permutations of ' + string | |
if __name__ == '__main__': | |
print 'Usage:{0} thread_size task_count'.format(sys.argv[0]) | |
try: | |
thread_size = int(sys.argv[1]) | |
task_count = int(sys.argv[2]) | |
except: | |
thread_size = 4 | |
task_count = 4 | |
print 'Using thread_size:{0} task_count:{1}'.format(thread_size, task_count) | |
p = Pool(thread_size) | |
s = 'ABCDEFGHIJ' | |
tasks = [s] * task_count | |
print('GO') | |
print(p.map(do_permutations, tasks)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment