a
    ‹©lcŽ  ã                   @   s–   d Z ddlZzddlZW n ey.   dZY n0 edurdeedƒrddd„ Zdd„ Zdd	„ Zd
d„ Znej	 Z ZZdd„ Zdd„ Z
dd„ Zdd„ ZdS )z&
Utilities for timing code execution.
é    NÚ	getrusagec                   C   s   t  t j¡d S )zåclocku() -> floating point number

        Return the *USER* CPU time in seconds since the start of the process.
        This is done via a call to resource.getrusage, so it avoids the
        wraparound problems in time.clock().r   ©Úresourcer   ÚRUSAGE_SELF© r   r   úP/var/www/html/django/DPS/env/lib/python3.9/site-packages/IPython/utils/timing.pyÚclocku   s    r   c                   C   s   t  t j¡d S )zçclocks() -> floating point number

        Return the *SYSTEM* CPU time in seconds since the start of the process.
        This is done via a call to resource.getrusage, so it avoids the
        wraparound problems in time.clock().é   r   r   r   r   r   Úclocks(   s    r
   c                  C   s    t  t j¡dd… \} }| | S )zòclock() -> floating point number

        Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
        the process.  This is done via a call to resource.getrusage, so it
        avoids the wraparound problems in time.clock().Né   r   )ÚuÚsr   r   r   Úclock1   s    r   c                   C   s   t  t j¡dd… S )zcclock2() -> (t_user,t_system)

        Similar to clock(), but return a tuple of user/system times.Nr   r   r   r   r   r   Úclock2;   s    r   c                   C   s   t  ¡ dfS )zeUnder windows, system CPU time can't be measured.

        This just returns process_time() and zero.g        )ÚtimeÚprocess_timer   r   r   r   r   F   s    c           
      O   s”   t | ƒ} | dksJ dƒ‚| dkr@tƒ }||i |¤Ž}tƒ | }nBt| d ƒ}tƒ }|D ]}||i |¤Ž qV||i |¤Ž}tƒ | }||  }	||	|fS )a0  timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)

    Execute a function reps times, return a tuple with the elapsed total
    CPU time in seconds, the time per call and the function's output.

    Under Unix, the return value is the sum of user+system time consumed by
    the process, computed via the resource module.  This prevents problems
    related to the wraparound effect which the time.clock() function has.

    Under Windows the return value is in wall clock seconds. See the
    documentation for the time module for more details.r	   zreps must be >= 1)Úintr   Úrange)
ÚrepsÚfuncÚargsÚkwÚstartÚoutZtot_timeÚrngÚdummyZav_timer   r   r   Útimings_outM   s    
r   c                 O   s    t | |g|¢R i |¤Ždd… S )zètimings(reps,func,*args,**kw) -> (t_total,t_per_call)

    Execute a function reps times, return a tuple with the elapsed total CPU
    time in seconds and the time per call. These are just the first two values
    in timings_out().r   r   ©r   )r   r   r   r   r   r   r   Útimingsj   s    r   c                 O   s   t d| g|¢R i |¤Žd S )z¡timing(func,*args,**kw) -> t_total

    Execute a function once, return the elapsed total CPU time in
    seconds. This is just the first value in timings_out().r	   r   r   )r   r   r   r   r   r   Útimingt   s    r   )Ú__doc__r   r   ÚImportErrorÚhasattrr   r
   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   
		

	
