ok

Mini Shell

Direktori : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/profile.cpython-36.opt-2.pyc

3


 \
V�@s�ddlZddlZddlZddlZddlmZdddgZGdd�d�Zdd	d�Zdd
d�Z	Gdd�d�Z
dd
�Zedkr|e�dS)�N)�OptionParser�run�runctx�Profilec@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�_UtilscCs
||_dS)N)�profiler)�selfr�r	�/usr/lib64/python3.6/profile.py�__init__1sz_Utils.__init__cCsF|j�}z(y|j|�Wntk
r,YnXWd|j|||�XdS)N)rr�
SystemExit�_show)r�	statement�filename�sort�profr	r	r
r4s
z
_Utils.runcCsJ|j�}z,y|j|||�Wntk
r0YnXWd|j|||�XdS)N)rrrr
)rr�globals�localsrrrr	r	r
r=s
z
_Utils.runctxcCs"|dk	r|j|�n
|j|�dS)N)�
dump_stats�print_stats)rrrrr	r	r
r
Fsz_Utils._showN)�__name__�
__module__�__qualname__rrrr
r	r	r	r
r+s		r�cCstt�j|||�S)N)rrr)rrrr	r	r
rRscCstt�j|||||�S)N)rrr)rrrrrr	r	r
r_sc@s�eZdZdZd3dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
e	eeeed�Z
dd�ZGdd�d�ZGdd�d�Zdd�Zdd�Zd5d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd6d/d0�Zd1d2�ZdS)7rrNcCs�i|_d|_d|_d|_|dkr&|j}||_|sHtj|_|_|j	|_
nl||_|j�}yt|�}Wn"tk
r�||_|j	|_
Yn0X|dkr�|j
|_
n|j|_
|tfdd�}||_|j�|_|jd�dS)N��cSs
||��S)Nr	)�timer�sumr	r	r
�get_time_timer�sz(Profile.__init__.<locals>.get_time_timerr)�timings�cur�cmd�c_func_name�bias�timeZprocess_timer�get_time�trace_dispatch_i�
dispatcher�len�	TypeError�trace_dispatch�trace_dispatch_lr�t�
simulate_call)rrr#r,Zlengthrr	r	r
r�s0


zProfile.__init__cCs�|j}|�}|d|d|j|j}|dkr8|j|_|j||||�rd|�}|d|d|_n|�}|d|d||_dS)Nrr�c_call)rr,r#rr"�dispatch)r�frame�event�argrr,�rr	r	r
r*�szProfile.trace_dispatchcCsT|j}|�|j|j}|dkr(|j|_|j||||�rD|�|_n|�||_dS)Nr.)rr,r#rr"r/)rr0r1r2rr,r	r	r
r&�s
zProfile.trace_dispatch_icCs`|j}|�d|j|j}|dkr,|j|_|j||||�rL|�d|_n|�d||_dS)NgN@r.)rr,r#rr"r/)rr0r1r2rr,r	r	r
�trace_dispatch_mac�szProfile.trace_dispatch_maccCsT|j}|�|j|j}|dkr(|j|_|j||||�rD|�|_n|�||_dS)Nr.)r%r,r#rr"r/)rr0r1r2r%r,r	r	r
r+�s
zProfile.trace_dispatch_lc	CsD|j\}}}}}}||k	r*|r*|j||�S|||||||f|_dS)Nr)r �trace_dispatch_return)	rr0r,�rpt�rit�ret�rfn�rframe�rcurr	r	r
�trace_dispatch_exception�s
z Profile.trace_dispatch_exceptioncCs�|jr@|j|jdk	r@|j\}}}}}}t|tj�s@|j|d�|j}	|	j|	j|	j	f}
|dd|
||jf|_|j
}|
|kr�||
\}}
}}}||
d|||f||
<nddddif||
<dS)Nrrr���)r �f_back�
isinstancer�
fake_framer5�f_code�co_filename�co_firstlineno�co_namer)rr0r,r6r7r8r9r:r;Zfcode�fnr�cc�ns�tt�ct�callersr	r	r
�trace_dispatch_callszProfile.trace_dispatch_callc
Csndd|jf}|dd|||jf|_|j}||krX||\}}}}}	||d|||	f||<nddddif||<dS)Nrrr)r"r r)
rr0r,rErrFrGrHrIrJr	r	r
�trace_dispatch_c_callszProfile.trace_dispatch_c_callcCs�||jdk	r |j|jdd�|j\}}}}}}||}||}|\}	}
}}}
}|	|
|||||
|f|_|j}||\}}}}}|s�||}|d}||kr�||d||<nd||<||d||||f||<dS)Nrrrr=r=)r r5r)rr0r,r6r7r8r9r;Zframe_totalZpptZpitZpetZpfn�pframeZpcurrrFrGrHrIrJr	r	r
r5#s"zProfile.trace_dispatch_return)�callZ	exception�returnr.Zc_exceptionZc_returncCs"|jdrdS||_|j|�dS)Nr���)r r!r-)rr!r	r	r
�set_cmdYs
zProfile.set_cmdc@seZdZdd�Zdd�ZdS)zProfile.fake_codecCs||_||_||_d|_dS)Nr)rB�co_linerDrC)rr�line�namer	r	r
r_szProfile.fake_code.__init__cCst|j|j|jf�S)N)�reprrBrRrD)rr	r	r
�__repr__eszProfile.fake_code.__repr__N)rrrrrVr	r	r	r
�	fake_code^srWc@seZdZdd�ZdS)zProfile.fake_framecCs||_||_dS)N)rAr>)r�codeZpriorr	r	r
riszProfile.fake_frame.__init__N)rrrrr	r	r	r
r@hsr@cCsF|jdd|�}|jr |jd}nd}|j||�}|jd||d�dS)NZprofilerrrNr=)rWr r@r/)rrTrXrMr0r	r	r
r-mszProfile.simulate_callcCsN|j}|�|j}x*|jdr<|jd||jd|�d}qW|�||_dS)NrrOrrrPr=)r%r,r r/)rr%r,r	r	r
�simulate_cmd_completeyszProfile.simulate_cmd_completercCs$ddl}|j|�j�j|�j�dS)Nr)�pstatsZStatsZ
strip_dirsZ
sort_statsr)rrrZr	r	r
r�szProfile.print_statsc
Cs0t|d��}|j�tj|j|�WdQRXdS)N�wb)�open�create_stats�marshal�dump�stats)r�file�fr	r	r
r�szProfile.dump_statscCs|j�|j�dS)N)rY�snapshot_stats)rr	r	r
r]�szProfile.create_statsc	Csfi|_xZ|jj�D]L\}\}}}}}|j�}d}x|j�D]}||7}q:W|||||f|j|<qWdS)Nr)r`r�items�copy�values)	r�funcrFrGrHrIrJZncZcallcntr	r	r
rc�szProfile.snapshot_statscCsddl}|j}|j|||�S)Nr)�__main__�__dict__r)rr!rh�dictr	r	r
r�szProfile.runcCs8|j|�tj|j�zt|||�Wdtjd�X|S)N)rQ�sys�
setprofiler'�exec)rr!rrr	r	r
r�s
zProfile.runctxcOs6|jt|��tj|j�z
|||�Stjd�XdS)N)rQrUrkrlr')rrg�args�kwr	r	r
�runcall�s

zProfile.runcallcCs8|jtk	rtd��|j}d|_z|j||�S||_XdS)Nz&Subclasses must override .calibrate().r)�	__class__rr)r#�_calibrate_inner)r�m�verboseZ
saved_biasr	r	r
�	calibrate�s
zProfile.calibratecCs$|j}dd�}|fdd�}||�|�}||�|�}||}|rLtd|�t�}	|�}|	jdt�t��|�}||}
|r�td|
�d}d}x>|	jj�D]0\\}
}}\}}}}}|dkr�||7}||7}q�W|r�td|�td|�||d
k�rtd|��||d|}|�r td|�|S)NcSsxt|�D]}d}q
WdS)Nr)�range)�n�i�xr	r	r
�f1�sz$Profile._calibrate_inner.<locals>.f1cSsxt|�D]}|d�q
WdS)N�d)rv)rsrzrxr	r	r
rb�sz#Profile._calibrate_inner.<locals>.fz elapsed time without profiling =zf(m)zelapsed time with profiling =grbrzz!'CPU seconds' profiler reported =ztotal # calls =rz internal error: total calls = %dg@z+mean stopwatch overhead per profile event =)rbrz)	r%�printrrrrrrd�
ValueError)rrsrtr%rzrbZt0Zt1Zelapsed_noprofile�pZelapsed_profileZtotal_callsZ
reported_timerrS�funcnamerFrGrHrIrJZmeanr	r	r
rr�sB

"


zProfile._calibrate_inner)NNrP)rP)r)rrrr#rr*r&r4r+r<rKrLr5r/rQrWr@r-rYrrr]rcrrrprurrr	r	r	r
rhs<'
''




1
c
Cs�d}t|d�}d|_|jdddddd�|jd	d
dddd�tjd
d�s\|j�tjd�|j�\}}|tjdd�<t|�dkr�|d}tj	j
dtj	j|��t
|d��}t|j�|d�}WdQRX|dddd�}t||d|j|j�n|j�|S)Nz?profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...)�usageFz-oz	--outfile�outfilezSave stats to <outfile>)�dest�help�defaultz-sz--sortrz?Sort order when printing to stdout, based on pstats.Stats classrrr�rbrmrh)�__file__r�__package__�
__cached__rP)rZallow_interspersed_argsZ
add_optionrk�argvZprint_usage�exit�
parse_argsr(�path�insert�os�dirnamer\�compile�readrr�r)r��parserZoptionsrnZprogname�fprXZglobsr	r	r
�main*s2




r�rhrP)NrPrP)NrP)
rkr�r$r^Zoptparser�__all__rrrrr�rr	r	r	r
�<module>s

'

	E"

Zerion Mini Shell 1.0