Format: application/x-python-code
⬇ Download File (3.5 KB)
   1  o
   2  
   3  ��h��@s�dZddlZzddlZWneydZYnwedur2eed�r2dd�Zdd�Zdd	�Zd
   4  d�Znej	ZZZdd�Zd
   5  d�Z
   6  dd�Zdd�ZdS)z&
   7  Utilities for timing code execution.
   8  �N�	getrusagecC�t�tj�dS)z�clocku() -> floating point number
   9  
  10          Return the *USER* CPU time in seconds since the start of the process.
  11          This is done via a call to resource.getrusage, so it avoids the
  12          wraparound problems in time.clock().r��resourcerZRUSAGE_SELF�rr�Jc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/timing.py�clocku�rcCr)z�clocks() -> floating point number
  13  
  14          Return the *SYSTEM* CPU time in seconds since the start of the process.
  15          This is done via a call to resource.getrusage, so it avoids the
  16          wraparound problems in time.clock().�rrrrr�clocks(r	rcCs t�tj�dd�\}}||S)z�clock() -> floating point number
  17  
  18          Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
  19          the process.  This is done via a call to resource.getrusage, so it
  20          avoids the wraparound problems in time.clock().N�r)�u�srrr�clock1srcCst�tj�dd�S)zcclock2() -> (t_user,t_system)
  21  
  22          Similar to clock(), but return a tuple of user/system times.Nrrrrrr�clock2;srcCst��dfS)zeUnder windows, system CPU time can't be measured.
  23  
  24          This just returns process_time() and zero.g)�time�process_timerrrrrFsc
  25  Os�t|�}|dksJd��|dkr t�}||i|��}t�|}n!t|d�}t�}|D]	}||i|��q+||i|��}t�|}||}	||	|fS)a0timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
  26  
  27      Execute a function reps times, return a tuple with the elapsed total
  28      CPU time in seconds, the time per call and the function's output.
  29  
  30      Under Unix, the return value is the sum of user+system time consumed by
  31      the process, computed via the resource module.  This prevents problems
  32      related to the wraparound effect which the time.clock() function has.
  33  
  34      Under Windows the return value is in wall clock seconds. See the
  35      documentation for the time module for more details.r
  36  zreps must be >= 1)�intr�range)
  37  �reps�func�args�kw�start�outZtot_time�rng�dummyZav_timerrr�timings_outMs
  38  
  39  
  40  rcOs t||g|�Ri|��dd�S)z�timings(reps,func,*args,**kw) -> (t_total,t_per_call)
  41  
  42      Execute a function reps times, return a tuple with the elapsed total CPU
  43      time in seconds and the time per call. These are just the first two values
  44      in timings_out().rr�r)rrrrrrr�timingsjs rcOstd|g|�Ri|��dS)z�timing(func,*args,**kw) -> t_total
  45  
  46      Execute a function once, return the elapsed total CPU time in
  47      seconds. This is just the first value in timings_out().r
  48  rr)rrrrrr�timingtsr )
  49  �__doc__rr�ModuleNotFoundError�hasattrrrrrrrrr rrrr�<module>s"�		
  50  
  51  	
  52