Skip to content

Instantly share code, notes, and snippets.

@doppiomacchiatto
Forked from tott/gist:3895832
Created January 22, 2017 23:53
Show Gist options
  • Save doppiomacchiatto/c9bfb52200d9fbaa914c198986904079 to your computer and use it in GitHub Desktop.
Save doppiomacchiatto/c9bfb52200d9fbaa914c198986904079 to your computer and use it in GitHub Desktop.
create cpu load in python
#!/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