Commit 40dea6bb authored by timo.specht's avatar timo.specht
Browse files

🍱 Benchmarks Added

parent 30947a18
import cProfile
import numpy as np
import matplotlib.pyplot as plt
import random
import timeit
from curvepy.bezier_curve import *
def gen_pts(n=12):
xs, ys = [random.random() * 40 - 20 for _ in range(n)], [random.random() * 40 - 20 for _ in range(n)]
return np.array([xs, ys])
def main(start, end, step):
curves = [BezierCurveMonomial] # BezierCurveDeCaes, BezierCurveBernstein, BezierCurveHorner, BezierCurveApproximation
points = {c : [] for c in curves}
print("hello")
for cnt_p in range(start, end, step):
print("hello")
times = {c : [] for c in curves}
for _ in range(1):
pts = gen_pts(n=cnt_p)
for c in curves:
b = c(pts)
t = timeit.timeit('b.curve', globals=locals())
times[c].append(t)
for c in curves:
points[c].append((cnt_p, sum(times[c])/len(times[c])))
for c in curves:
plt.plot([x[0] for x in points[c]], [x[1] for x in points[c]])
plt.legend([c for c in curves])
plt.show()
if __name__ == '__main__':
main(start=1, end=1000, step=50)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment