o
    :Î®cŽ  ã                   @   s   d dl Z G dd„ deƒZdS )é    Nc                   @   s"   e Zd ZdZdd„ Zddd„ZdS )ÚTimerzTimer for benchmarkingc                 C   s   t  ¡ | _dS )zStarts a timerN)ÚtimeÚperf_counterÚt)Úself© r   ú;/tmp/pip-target-vg8gfxp4/lib/python/pymatting/util/timer.pyÚ__init__   s   zTimer.__init__Nc                 C   s2   t  ¡ | j }|durt|d| ƒ t  ¡ | _|S )aï  Return and print time since last stop-call or initialization.
        Also print elapsed time if message is provided.

        Parameters
        ----------
        message: str
            Message to print in front of passed seconds

        Example
        -------
        >>> from pymatting import *
        >>> t = Timer()
        >>> t.stop()
        2.6157200919999966
        >>> t = Timer()
        >>> t.stop('Test')
        Test  - 11.654551 seconds
        11.654551381000001
        Nz - %f seconds)r   r   r   Úprint)r   ÚmessageÚ
delta_timer   r   r   Ústop   s
   
z
Timer.stop)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r      s    r   )r   Úobjectr   r   r   r   r   Ú<module>   s    