import timeit import numpy as np import matplotlib.pyplot as plt def escape(z, c, maximum: int, bounds: float): i = 0 while abs(z) < bounds and i < maximum: z = z ** 2 + c i += 1 return i maxima = 100 v_escape = np.vectorize(escape) def grid(n): return np.array([[ complex(a,b) for b in np.linspace(-2, 2, num=n)] for a in np.linspace(-2, 2, num=n)], dtype=np.csingle) def calculate(grid, i): return v_escape(0, grid, i, 2) samples = np.zeros(maxima) for i in range(2,maxima+1): cgrid = grid(i) duration = min(timeit.Timer(lambda : calculate(cgrid, 10)).repeat(10, 10)) samples[i-1] = duration print(i) plt.grid(visible=True) plt.plot(samples, label="python") #plt.plot(, label ="julia") plt.legend() plt.xlabel("Rastergröße n") plt.ylabel("Zeit in Sekunden") plt.show() print(",".join(map(str, samples)))