Skip to content

Instantly share code, notes, and snippets.

@tott
Created November 27, 2012 11:19
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 tott/4153726 to your computer and use it in GitHub Desktop.
Save tott/4153726 to your computer and use it in GitHub Desktop.
produce_load.py
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
x*x
if __name__ == '__main__':
processes = cpu_count()
print 'utilizing %d cores\n' % processes
pool = Pool(processes)
pool.map(f, range(processes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment