
    Wh                         d Z ddlZddlZddlZddlZddlmZ  ej                    Zd	dZ	 G d dej
                  Z e            Zej        d             Zd ZdS )
z%Utilities for measuring elapsed time.    N)
tb_loggingc                     |t           j        }t          | t                    r| }t	          ||          S | }t          |dd          }|t          |          }t	          ||          } ||          S )a  Log latency in a function or region.

    Three usages are supported. As a decorator:

    >>> @log_latency
    ... def function_1():
    ...     pass
    ...


    As a decorator with a custom label for the region:

    >>> @log_latency("custom_label")
    ... def function_2():
    ...     pass
    ...

    As a context manager:

    >>> def function_3():
    ...     with log_latency("region_within_function"):
    ...         pass
    ...

    Args:
        region_name_or_function_to_decorate: Either: a `str`, in which
            case the result of this function may be used as either a
            decorator or a context manager; or a callable, in which case
            the result of this function is a decorated version of that
            callable.
        log_level: Optional integer logging level constant. Defaults to
            `logging.INFO`.

    Returns:
        A decorated version of the input callable, or a dual
        decorator/context manager with the input region name.
    N__qualname__)loggingINFO
isinstancestr_log_latencygetattr)#region_name_or_function_to_decorate	log_levelregion_namefunction_to_decoratequalname	decorators         ]/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/tensorboard/util/timing.pylog_latencyr      s    N L	5s;; 	/9K333B/FF/00H 955	y-...    c                       e Zd Zd ZdS )_ThreadLocalStorec                     d| _         d S )Nr   )nesting_level)selfs    r   __init__z_ThreadLocalStore.__init__R   s    r   N)__name__
__module__r   r    r   r   r   r   Q   s#            r   r   c           	   #     K   t                               |          sd V  d S t          j        }	 t	          j                    }|dz   t          _        d|z  }t          j                    }d|j        |j        |fz  }t          |d||            d V  |t          _        t	          j                    |z
  }t          |d|| |           d S # |t          _        t	          j                    |z
  }t          |d|| |           w xY w)N   z  z%s[%x]%sz%s ENTER %sz%s LEAVE %s - %0.6fs elapsed)
loggerisEnabledFor_storer   time	threadingcurrent_threadnameident_log)r&   r   start_levelstartedindentthreadprefixelapseds           r   r
   r
   Y   s     y)) &K
)++*Q[()++v{FL&AAYvt444*)++'*	
 	
 	
 	
 	
  +)++'*	
 	
 	
 	
s   A"C	 	7D c                 ,    t          j        | |g|R   d S N)r    log)r   msgargss      r   r(   r(   t   s$     Jy#%%%%%%%r   r0   )__doc__
contextlibr   r$   r#   tensorboard.utilr   
get_loggerr    r   localr   r"   contextmanagerr
   r(   r   r   r   <module>r:      s    , +           ' ' ' ' ' '			 	 3/ 3/ 3/ 3/l    	   
 
			 
 
 
4& & & & &r   