B
    ed                 @   s^   d Z ddlZddlZddddgZddd	d
gZdddZdd Ze adadddZ	dd Z
dS )zMSimple tools for timing functions' execution, when IPython is not available.     Ng      ?g     @@g    .Ag    eAsmsu   μsnspassc       	      C   s   t j| |d}d\}}x@tddD ]2}| |dkr8P q"|dk	rL||krLP q"|d9 }q"W t|||| }|dkrtttt|d  d}nd}|||t	|  t
| fS )	z1Adaptively measure execution time of a function. )setup)      r   
   g?Ng        r   )timeitTimerrangeminrepeatintmathfloorlog10_scales_units)	funcr   limittimerr   numberitimeorder r   f/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sympy/utilities/timeutils.pytimed   s    "r   c              C   s0   dd l } | dd}dd |dD }t|S )Nr   ZSYMPY_TIMINGS c             S   s   g | ]}|  qS r   )strip).0xr   r   r   
<listcomp>(   s    z __do_timings.<locals>.<listcomp>,)osgetenvsplitset)r%   resr   r   r   __do_timings%   s    r*   r   c             C   sH   t d| d| d | d | d f  x| d D ]}t||d  q.W d S )N-z	%.2f %s%s   r   r   r   )print_print_timestack)stacklevelr   r   r   r   r.   /   s    $r.   c                s    fdd}|S )Nc                s   t kr S  fdd}|S )Nc                 sl   ddl m } t} jg d| ga| } | |}| }|| td< |d k	r\|d t |antt d a|S )Nr   )r   r,   r   )r   
_timestack	func_nameappendr.   )argskwargsr   Zoldtimestackt1rt2)r   r   r   wrapper;   s    
z,timethis.<locals>.decorator.<locals>.wrapper)_do_timings)r   r9   )name)r   r   	decorator6   s    ztimethis.<locals>.decoratorr   )r;   r<   r   )r;   r   timethis5   s    r=   )r   N)r   )__doc__r
   r   r   r   r   r*   r:   r1   r.   r=   r   r   r   r   <module>   s   

