Skip to content

Instantly share code, notes, and snippets.

@itsPG
Created November 22, 2015 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsPG/96512553c6ed3592daa8 to your computer and use it in GitHub Desktop.
Save itsPG/96512553c6ed3592daa8 to your computer and use it in GitHub Desktop.
python benchmark
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