← Back
Editing: timing.cpython-311.pyc
� �@�c� � � � d Z ddlZ ddlZn # e$ r dZY nw xY we� eed� � r d� Zd� Zd� Zd� Znej xZxZZd� Zd � Z d � Zd� ZdS )z& Utilities for timing code execution. � N� getrusagec �J � t j 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� � �6/usr/lib/python3/dist-packages/IPython/utils/timing.py�clockur � � � �!�(�"6�7�7��:�:r c �J � t j 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 �clocksr ( r r c �^ � t j t j � � dd� \ } }| |z 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�ss r �clockr 1 s- � � � ��!5�6�6�r��r�:���!���s� r c �N � t j t j � � dd� S )zcclock2() -> (t_user,t_system) Similar to clock(), but return a tuple of user/system times.Nr r r r r �clock2r ; s! � � �!�(�"6�7�7����;�;r c �, � t j � � dfS )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�'�'r c �< � t | � � } | dk s J d� � �| dk r(t � � } ||i |��}t � � |z }nFt | dz � � }t � � }|D ] } ||i |�� � ||i |��}t � � |z }|| z } || |fS )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 zreps must be >= 1)�intr �range) �reps�func�args�kw�start�out�tot_time�rng�dummy�av_times r �timings_outr'