Page MenuHomec4science

stress.py
No OneTemporary

File Metadata

Created
Thu, Dec 19, 12:18

stress.py

import time
import sys
from multiprocessing import Pool
m_100=4_000_000 # 1.23 secs
m_1G=45_000_000 # 3.47
m_10G=450_000_000 # 26 secs
ncpus = 1
if len(sys.argv) > 1:
ncpus = int(sys.argv[1])
def kernel(n, t=2):
str1 = 'aBcd'*n
str1.replace('aB', 'z11aaa')
str1.swapcase()
time.sleep(t)
print("Kernel finished")
if __name__ == '__main__':
inputs = [m_1G] * 30
with Pool(ncpus) as p:
p.map(kernel, inputs)
print(f"Run finished")

Event Timeline