Format: application/x-python-code
1 o
2
3 ��h� � @ s� d Z ddlZzddlZW n ey dZY nw edur2eed�r2dd� Zdd� Zdd � Zd
4 d� Znej Z ZZdd� Zd
5 d� Z
6 dd� Zdd� ZdS )z&
7 Utilities for timing code execution.
8 � N� getrusagec C � t �t j�d S )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 ��resourcer ZRUSAGE_SELF� r r �Jc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/timing.py�clocku � r c C r )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().� r r r r r �clocks( r r c C s t �t j�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�sr r r �clock1 s r c C s t �t j�dd� S )zcclock2() -> (t_user,t_system)
21
22 Similar to clock(), but return a tuple of user/system times.Nr r r r r r �clock2; s r c C s t �� dfS )zeUnder windows, system CPU time can't be measured.
23
24 This just returns process_time() and zero.g )�time�process_timer r r r r F s c
25 O s� t | �} | dksJ d��| dkr t� }||i |��}t� | }n!t| d �}t� }|D ] }||i |�� q+||i |��}t� | }|| } || |fS )a0 timings_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_timer r r �timings_outM s
38
39
40 r c O s t | |g|�R i |��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().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
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 r r )r r r r r r �timingt s r )
49 �__doc__r r �ModuleNotFoundError�hasattrr r r r r r r r r r r r �<module> s"