Ë
    x[hg  ã                   óp   — d dl Z d dlZd dlZ ej                  e«      Z G d„ d«      Zdddœdededefd	„Z	y)
é    Nc                   ó8   — e Zd ZdZdddœdededefd„Zd„ Zd	„ Zy
)ÚTimeda¾  
    A context manager which measures and optionally logs context run time.

    :param msg: A message that describes the thing that is being measured
    :param threshold: Threshold, in seconds. When the context exceeds this
        threshold, a log will be made.
    :param log_mode: Control whether to log. Defaults to "threshold". Possible
        values include:
        "always" - Always log 'msg', even when 'threshold' is not reached.
        "threshold" - Log when context time exceeds 'threshold'.
        "skip" - Do not log. Context time and message are stored in the
            'output' and 'delta' attributes, respectively. Used to manually
            coalesce with other logs at the call site.

    usage:

        this call:
        ```
        with Timed("Configuring the network"):
            run_configure()
        ```

        might produce this log:
        ```
            Configuring the network took 0.100 seconds
        ```
    ç{®Gáz„?Ú	threshold©r   Úlog_modeÚmsgr   c                óX   — || _         || _        || _        d| _        d| _        d| _        y )NÚ g        )r	   r   r   ÚoutputÚstartÚdelta)Úselfr	   r   r   s       ú7/usr/lib/python3/dist-packages/cloudinit/performance.pyÚ__init__zTimed.__init__%   s.   € ð ˆŒØ"ˆŒØ ˆŒØˆŒØˆŒ
Øˆ�
ó    c                 ó8   — t        j                  «       | _        | S )N)ÚtimeÚ	monotonicr   )r   s    r   Ú	__enter__zTimed.__enter__3   s   € Ü—^‘^Ó%ˆŒ
Øˆr   c                 óæ  — t        j                  «       | j                  z
  | _        d| j                  d›d�}d| j                  k(  r"t
        j                  d| j                  |«       y d| j                  k(  ry d| j                  k(  rR| j                  | j                  kD  r8t
        j                  d| j                  |«       | j                  › d|› �| _	        y y t        d	| j                  › d
�«      ‚)Nztook z.3fz secondsÚalwaysz%s %sÚskipr   ú zInvalid Timed log_mode value: 'z'.)r   r   r   r   r   ÚLOGÚdebugr	   r   r   Ú
ValueError)r   Úexc_typeÚexc_valÚexc_tbÚsuffixs        r   Ú__exit__zTimed.__exit__7   sÇ   € Ü—^‘^Ó%¨¯
©
Ñ2ˆŒ
Ø˜Ÿ™ CÐ(¨Ð1ˆØ�t—}‘}Ò$Ü�I‰I�g˜tŸx™x¨Õ0Ø�t—}‘}Ò$ØØ˜DŸM™MÒ)Ø�z‰z˜DŸN™NÒ*Ü—	‘	˜' 4§8¡8¨VÔ4Ø!%§¡ 
¨!¨F¨8Ð4�•ð +ô Ø1°$·-±-°ÀÐCóð r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚfloatr   r   r"   © r   r   r   r      s;   „ ñð@  Ø#òàðð ð	ð
 óòór   r   r   r   r   r	   r   c                ó   ‡ ‡‡— ˆˆ ˆfd„}|S )aù  
    A decorator which measures and optionally logs context run time.

    :param msg: A message that describes the thing that is being measured
    :param threshold: Threshold, in seconds. When the context exceeds this
        threshold, a log will be made.
    :param log_mode: Control whether to log. Defaults to "threshold". Possible
        values include:
        "always" - Always log 'msg', even when 'threshold' is not reached.
        "threshold" - Log when context time exceeds 'threshold'.

    usage:

        this call:
        ```
        @timed("Configuring the network")
        def run_configure():
            ...
        ```

        might produce this log:
        ```
            Configuring the network took 0.100 seconds
        ```
    c                 óJ   •‡ — t        j                  ‰ «      ˆ ˆˆˆfd„«       }|S )Nc                  ó\   •— t        ‰‰‰¬«      5   ‰| i |¤Žcd d d «       S # 1 sw Y   y xY w)Nr   )r   )ÚargsÚkwargsÚfuncr   r	   r   s     €€€€r   Ú	decoratorz)timed.<locals>.wrapper.<locals>.decoratord   s1   ø€ ä�s i¸(ÔCñ -Ù˜TÐ, VÑ,÷-÷ -ò -ús   �"¢+)Ú	functoolsÚwraps)r/   r0   r   r	   r   s   ` €€€r   Úwrapperztimed.<locals>.wrapperc   s&   ù€ Ü	�‰˜Ó	ö	-ó 
ð	-ð Ðr   r)   )r	   r   r   r3   s   ``` r   Útimedr4   H   s   ú€ ö6ð €Nr   )
r1   Úloggingr   Ú	getLoggerr#   r   r   r'   r(   r4   r)   r   r   ú<module>r7      sL   ðÛ Û Û à€g×Ñ˜Ó!€÷=ñ =ð@ +/Àò #ˆsð # %ð #¸#ô #r   