@@ -0,0 +1,2230 @@
+# Copyright (c) 2020, Manfred Moitzi%0A# License: MIT License%0Aimport sys%0Aimport time%0Afrom datetime import datetime%0Afrom pathlib import Path%0Afrom ezdxf.acc import USE_C_EXT%0A%0Aif USE_C_EXT is False:%0A    print('C-extension disabled or not available.')%0A    sys.exit(1)%0A%0Afrom ezdxf.math.bezier4p import Bezier4P%0Afrom ezdxf.acc.bezier4p import Bezier4P as CBezier4P%0Afrom ezdxf.version import __version__%0A%0APOINTS = %5B(0, 0), (1, 0), (1, 1), (0, 1)%5D%0A%0A%0Adef open_log(name: str):%0A    parent = Path(__file__).parent%0A    p = parent / 'logs' / Path(name + '.csv')%0A    if not p.exists():%0A        with open(p, mode='wt') as fp:%0A            fp.write(%0A                '%22timestamp%22; %22pytime%22; %22cytime%22; '%0A                '%22python_version%22; %22ezdxf_version%22%5Cn')%0A    log_file = open(p, mode='at')%0A    return log_file%0A%0A%0Adef log(name: str, pytime: float, cytime: float):%0A    log_file = open_log(name)%0A    timestamp = datetime.now().isoformat()%0A    log_file.write(%0A        f'%7Btimestamp%7D; %7Bpytime%7D; %7Bcytime%7D; %22%7Bsys.version%7D%22; %22%7B__version__%7D%22%5Cn')%0A    log_file.close()%0A%0A%0Adef bezier4p_points(Curve, count):%0A    c = Curve(POINTS)%0A    for _ in range(count):%0A        c.point(0.5)%0A%0A%0Adef bezier4p_approximate(Curve, count):%0A    c = Curve(POINTS)%0A    for _ in range(count):%0A        list(c.approximate(32))%0A%0A%0Adef bezier4p_flattening(Curve, count):%0A    c = Curve(POINTS)%0A    for _ in range(count):%0A        list(c.flattening(0.01))%0A%0A%0Adef profile1(func, *args) -%3E float:%0A    t0 = time.perf_counter()%0A    func(*args)%0A    t1 = time.perf_counter()%0A    return t1 - t0%0A%0A%0Adef profile(text, func, pytype, cytype, *args):%0A    pytime = profile1(func, pytype, *args)%0A    cytime = profile1(func, cytype, *args)%0A    ratio = pytime / cytime%0A    print(f'Python - %7Btext%7D %7Bpytime:.3f%7Ds')%0A    print(f'Cython - %7Btext%7D %7Bcytime:.3f%7Ds')%0A    print(f'Ratio %7Bratio:.1f%7Dx')%0A    log(func.__name__, pytime, cytime)%0A%0A%0ARUNS = 1_000_000%0A%0Aprint(f'Profiling Bezier4P Python and Cython implementation:')%0Aprofile(f'calc %7BRUNS%7D points of Bezier4P: ', bezier4p_points, Bezier4P, CBezier4P, RUNS)%0Aprofile(f'100.000x approximate 32 points of Bezier4P: ', bezier4p_approximate, Bezier4P, CBezier4P, 100_000)%0Aprofile(f'100.000x flattening (0.01) of Bezier4P: ', bezier4p_flattening, Bezier4P, CBezier4P, 100_000)%0A

add profiling for Bezier4P