task.py 627 B
import time
import numpy as np
class Task:
def __init__(self, identifier):
self.identifier = identifier
# choosee the size of the problem
self.size = np.random.randint(2, 1000)
# Generate the input of the problem
self.a = np.random.rand(self.size, self.size)
self.b = np.random.rand(self.size)
# prepare room for the results
self.x = np.zeros((self.size))
self.time = 0
def work(self):
start = time.perf_counter()
self.x = self.b
self.x = np.linalg.solve(self.a, self.b)
self.time = time.perf_counter() - start