a
    Mˆc†  ã                   @   sf   d Z ddlT ddlZddlZdZdd„ Zdd	„ Zd
d„ Zddd„Zdd„ Z	e
dkrbe d¡ e	ƒ  dS )ú*Benchmark the cu2qu algorithm performance.é   )Ú*é    Né   c                   C   s   dd„ t dƒD ƒS )Nc                 S   s"   g | ]}t d d„ tdƒD ƒƒ‘qS )c                 s   s   | ]}t t d d¡ƒV  qdS )r   i   N)ÚfloatÚrandomÚrandint)Ú.0Zcoord© r
   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/fontTools/cu2qu/benchmark.pyÚ	<genexpr>   ó    z,generate_curve.<locals>.<listcomp>.<genexpr>é   )ÚtupleÚrange)r	   Zpointr
   r
   r   Ú
<listcomp>
   s   ÿz"generate_curve.<locals>.<listcomp>é   )r   r
   r
   r
   r   Úgenerate_curve	   s    þr   c                   C   s
   t ƒ tfS ©N)r   ÚMAX_ERRr
   r
   r
   r   Úsetup_curve_to_quadratic   s    r   c                  C   s    d} dd„ t | ƒD ƒtg|  fS )Né   c                 S   s   g | ]
}t ƒ ‘qS r
   )r   )r	   Zcurver
   r
   r   r      r   z-setup_curves_to_quadratic.<locals>.<listcomp>)r   r   )Z
num_curvesr
   r
   r   Úsetup_curves_to_quadratic   s    þr   Ú éè  c           	      C   sx   d| }|r.t d||f dd� |d| 7 }nt d| dd� dd„ }tj|||ƒ||d	�}t d
t|ƒd |  ƒ d S )NZsetup_z%s with %s:r   )ÚendÚ_z%s:c                    s&   t ƒ ˆ  ‰ t ƒ ˆ ‰‡ ‡fdd„}|S )Nc                      s
   ˆ ˆƒ Ž S r   r
   r
   ©ÚfunctionÚ
setup_funcr
   r   Úwrapped#   s    z/run_benchmark.<locals>.wrapper.<locals>.wrapped)Úglobals)r   r   r    r
   r   r   Úwrapper    s    

zrun_benchmark.<locals>.wrapper)ÚrepeatÚnumberz	%5.1fusg    €„.A)ÚprintÚtimeitr#   Úmin)	Zbenchmark_moduleÚmoduler   Zsetup_suffixr#   r$   r   r"   Úresultsr
   r
   r   Úrun_benchmark   s    r*   c                   C   s   t dddƒ t dddƒ dS )r   zcu2qu.benchmarkÚcu2quZcurve_to_quadraticZcurves_to_quadraticN)r*   r
   r
   r
   r   Úmain)   s    r,   Ú__main__)r   r   r   )Ú__doc__r+   r   r&   r   r   r   r   r*   r,   Ú__name__Úseedr
   r
   r
   r   Ú<module>   s    ÿ

