o
    þÏ¯iã  ã                   @   s*   d dl mZ d dlmZ G dd„ dƒZdS )é    )Úperf_counter)ÚOptionalc                   @   sb   e Zd ZdZddd„Zddd„Zddd	„Zdefd
d„Zddd„Z	de
fdd„Zde
fdd„ZdS )ÚTimerzU
    A timer which computes the time elapsed since the start/reset of the timer.
    ÚreturnNc                 C   s   |   ¡  d S )N)Úreset©Úself© r	   úG/home/ubuntu/.local/lib/python3.10/site-packages/fvcore/common/timer.pyÚ__init__   s   zTimer.__init__c                 C   s   t ƒ | _d| _d| _d| _dS )z"
        Reset the timer.
        Nr   é   )r   Ú_startÚ_pausedÚ_total_pausedÚ_count_startr   r	   r	   r
   r      s   
zTimer.resetc                 C   s   | j dur	tdƒ‚tƒ | _ dS )z"
        Pause the timer.
        Nz/Trying to pause a Timer that is already paused!)r   Ú
ValueErrorr   r   r	   r	   r
   Úpause   s   
zTimer.pausec                 C   s
   | j duS )zR
        Returns:
            bool: whether the timer is currently paused
        N)r   r   r	   r	   r
   Ú	is_paused!   s   
zTimer.is_pausedc                 C   s@   | j du r	tdƒ‚|  jtƒ | j  7  _d| _ |  jd7  _dS )z#
        Resume the timer.
        Nz,Trying to resume a Timer that is not paused!r   )r   r   r   r   r   r   r	   r	   r
   Úresume(   s
   
zTimer.resumec                 C   s(   | j dur	| j }ntƒ }|| j | j S )z¬
        Returns:
            (float): the total number of seconds since the start/reset of the
                timer, excluding the time when the timer is paused.
        N)r   r   r   r   )r   Úend_timer	   r	   r
   Úseconds4   s   
zTimer.secondsc                 C   s   |   ¡ | j S )z~
        Returns:
            (float): the average number of seconds between every start/reset and
            pause.
        )r   r   r   r	   r	   r
   Úavg_seconds@   s   zTimer.avg_seconds)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úboolr   r   Úfloatr   r   r	   r	   r	   r
   r      s    


	
r   N)Útimer   Útypingr   r   r	   r	   r	   r
   Ú<module>   s   