DAS_2024_1/bazunov_andrew_lab_5/main.py
Bazunov Andrew Igorevich 4b86dfd750 complete lab
2024-10-28 22:27:53 +04:00

28 lines
625 B
Python

import time
from collections.abc import Callable
from matrix import Matrix
from random import random
_THREADS = 20
def measure_time(func: Callable, *args) -> float:
t1 = time.process_time()
func(*args)
t2 = time.process_time()
return round(t2 - t1, 5)
tests = [50 * i for i in range(1, 21)]
for test in tests:
mt1 = Matrix(size=test, suplyer=random)
mt2 = Matrix(size=test, suplyer=random)
t1 = measure_time(lambda: mt1 * mt2)
t5 = measure_time(lambda: mt1 * (mt2, 5))
t20 = measure_time(lambda: mt1 * (mt2, 20))
print(f"|{f'{test}x{test}':<16}|{t1:^11}|{t5:^11}|{t20:^12}|")