Files
sunnypilot/scripts/waste.py
Adeeb Shihadeh a9626f95b6 add openpilot prefix to imports (#29498)
* add openpilot prefix to imports

* more

* more

* fix docs

* fix linter

* bump submodules

* fix patched tests

* update dynamic imports

* debug

* Revert "debug"

This reverts commit db5e13b9911cc74438bee123bc3430da6c31b24b.

* fix pm test
2023-08-20 20:49:55 -07:00

34 lines
703 B
Python
Executable File

#!/usr/bin/env python3
import os
import time
import numpy as np
from multiprocessing import Process
from setproctitle import setproctitle
def waste(core):
os.sched_setaffinity(0, [core,])
m1 = np.zeros((200, 200)) + 0.8
m2 = np.zeros((200, 200)) + 1.2
i = 1
st = time.monotonic()
j = 0
while 1:
if (i % 100) == 0:
setproctitle("%3d: %8d" % (core, i))
lt = time.monotonic()
print("%3d: %8d %f %.2f" % (core, 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(os.cpu_count()):
p = Process(target=waste, args=(i,))
p.start()
if __name__ == "__main__":
main()