2020-01-17 10:41:41 -08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import os
|
2023-08-20 18:50:58 -07:00
|
|
|
import time
|
2020-01-17 10:41:41 -08:00
|
|
|
import numpy as np
|
2020-12-18 16:12:58 -08:00
|
|
|
from multiprocessing import Process
|
2024-08-05 16:42:22 -07:00
|
|
|
from setproctitle import setproctitle
|
2020-01-17 10:41:41 -08:00
|
|
|
|
2020-12-18 16:12:58 -08:00
|
|
|
def waste(core):
|
2023-08-20 20:49:55 -07:00
|
|
|
os.sched_setaffinity(0, [core,])
|
2020-01-17 10:41:41 -08:00
|
|
|
|
2020-05-31 12:37:52 -07:00
|
|
|
m1 = np.zeros((200, 200)) + 0.8
|
|
|
|
|
m2 = np.zeros((200, 200)) + 1.2
|
2020-01-17 10:41:41 -08:00
|
|
|
|
|
|
|
|
i = 1
|
2023-08-20 18:50:58 -07:00
|
|
|
st = time.monotonic()
|
2020-01-17 10:41:41 -08:00
|
|
|
j = 0
|
|
|
|
|
while 1:
|
|
|
|
|
if (i % 100) == 0:
|
2024-12-04 15:34:54 -08:00
|
|
|
setproctitle(f"{core:3d}: {i:8d}")
|
2023-08-20 18:50:58 -07:00
|
|
|
lt = time.monotonic()
|
2024-12-04 15:34:54 -08:00
|
|
|
print(f"{core:3d}: {i:8d} {lt-st:f} {j:.2f}")
|
2020-01-17 10:41:41 -08:00
|
|
|
st = lt
|
|
|
|
|
i += 1
|
|
|
|
|
j = np.sum(np.matmul(m1, m2))
|
|
|
|
|
|
|
|
|
|
def main(gctx=None):
|
|
|
|
|
print("1-2 seconds is baseline")
|
2020-12-18 16:12:58 -08:00
|
|
|
for i in range(os.cpu_count()):
|
2020-01-17 10:41:41 -08:00
|
|
|
p = Process(target=waste, args=(i,))
|
|
|
|
|
p.start()
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|