CPU stress test script in python


SUBMITTED BY: kn1ghtm4r3

DATE: April 28, 2017, 3:33 p.m.

FORMAT: Python 3

SIZE: 359 Bytes

HITS: 13999

  1. #!/usr/bin/env python
  2. """
  3. Produces load on all available CPU cores
  4. """
  5. from multiprocessing import Pool
  6. from multiprocessing import cpu_count
  7. def f(x):
  8. while True:
  9. x*x
  10. if __name__ == '__main__':
  11. processes = cpu_count()
  12. print 'utilizing %d cores\n' % processes
  13. pool = Pool(processes)
  14. pool.map(f, range(processes))

comments powered by Disqus