2020-01-18 02:41:41 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from multiprocessing import Process
|
2020-05-28 11:00:14 +08:00
|
|
|
from setproctitle import setproctitle # pylint: disable=no-name-in-module
|
2020-01-18 02:41:41 +08:00
|
|
|
import os
|
|
|
|
import numpy as np
|
|
|
|
from common.realtime import sec_since_boot
|
|
|
|
|
|
|
|
def waste(pid):
|
|
|
|
# set affinity
|
|
|
|
os.system("taskset -p %d %d" % (1 << pid, os.getpid()))
|
|
|
|
|
2020-06-01 03:37:52 +08:00
|
|
|
m1 = np.zeros((200, 200)) + 0.8
|
|
|
|
m2 = np.zeros((200, 200)) + 1.2
|
2020-01-18 02:41:41 +08:00
|
|
|
|
|
|
|
i = 1
|
|
|
|
st = sec_since_boot()
|
|
|
|
j = 0
|
|
|
|
while 1:
|
|
|
|
if (i % 100) == 0:
|
|
|
|
setproctitle("%3d: %8d" % (pid, i))
|
|
|
|
lt = sec_since_boot()
|
|
|
|
print("%3d: %8d %f %.2f" % (pid, i, lt-st, j))
|
|
|
|
st = lt
|
|
|
|
i += 1
|
|
|
|
j = np.sum(np.matmul(m1, m2))
|
|
|
|
|
|
|
|
def main(gctx=None):
|
|
|
|
print("1-2 seconds is baseline")
|
|
|
|
for i in range(4):
|
|
|
|
p = Process(target=waste, args=(i,))
|
|
|
|
p.start()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|