AlkantarClanX12

Your IP : 18.226.226.151


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/profile.cpython-35.opt-2.pyc



���]V�@s�ddlZddlZddlZddlZddlmZdddgZGdd�d�Zddd	d�Zddd
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	�,/opt/alt/python35/lib64/python3.5/profile.py�__init__1sz_Utils.__init__cCsQ|j�}z*y|j|�Wntk
r4YnXWd|j|||�XdS)N)rr�
SystemExit�_show)r�	statement�filename�sort�profr	r	r
r4s
	z
_Utils.runcCsW|j�}z0y|j|||�Wntk
r:YnXWd|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@sneZdZdZdddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zde
de	dedededeiZ
dd�ZGdd�d�ZGdd �d �Zd!d"�Zd#d$�Zd8d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zdd4d5�Zd6d7�ZdS)9rrNcCsi|_d|_d|_d|_|dkr9|j}||_|sjtj|_|_|j	|_
n�||_|j�}yt|�}Wn'tk
r�||_|j	|_
YnCX|dkr�|j
|_
n|j|_
|tdd�}||_|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�time�process_timer�get_time�trace_dispatch_i�
dispatcher�len�	TypeError�trace_dispatch�trace_dispatch_lr�t�
simulate_call)rrr#r-�lengthrr	r	r
r�s0							
		zProfile.__init__cCs�|j}|�}|d|d|j|j}|dkrJ|j|_|j||||�r�|�}|d|d|_n"|�}|d|d||_dS)Nrr�c_call)rr-r#rr"�dispatch)r�frame�event�argrr-�rr	r	r
r+�s		 		zProfile.trace_dispatchcCst|j}|�|j|j}|dkr8|j|_|j||||�r`|�|_n|�||_dS)Nr0)rr-r#rr"r1)rr2r3r4rr-r	r	r
r'�s	zProfile.trace_dispatch_icCs�|j}|�d|j|j}|dkr<|j|_|j||||�rh|�d|_n|�d||_dS)NgN@r0)rr-r#rr"r1)rr2r3r4rr-r	r	r
�trace_dispatch_mac�s	zProfile.trace_dispatch_maccCst|j}|�|j|j}|dkr8|j|_|j||||�r`|�|_n|�||_dS)Nr0)r&r-r#rr"r1)rr2r3r4r&r-r	r	r
r,�s	zProfile.trace_dispatch_lc	Cs`|j\}}}}}}||k	r=|r=|j||�S|||||||f|_dS)Nr)r �trace_dispatch_return)	rr2r-�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_framer7�f_code�co_filename�co_firstlineno�co_namer)rr2r-r8r9r:r;r<r=Zfcode�fnr�cc�ns�tt�ct�callersr	r	r
�trace_dispatch_calls		 zProfile.trace_dispatch_callc
Cs�dd|jf}|dd|||jf|_|j}||kr~||\}}}}}	||d|||	f||<nddddif||<dS)Nrrr)r"r r)
rr2r-rGrrHrIrJrKrLr	r	r
�trace_dispatch_c_calls	 zProfile.trace_dispatch_c_callcCs ||jdk	r*|j|jdd�|j\}}}}}}||}||}|\}	}
}}}
}|	|
|||||
|f|_|j}||\}}}}}|s�||}|d}||kr�||d||<n
d||<||d||||f||<dS)Nrrrr?r?)r r7r)rr2r-r8r9r:r;r=Zframe_totalZpptZpitZpetZpfn�pframeZpcurrrHrIrJrKrLr	r	r
r7#s"

#	


!zProfile.trace_dispatch_return�call�	exception�returnr0Zc_exceptionZc_returncCs+|jdrdS||_|j|�dS)Nr���)r r!r.)rr!r	r	r
�set_cmdYs
	zProfile.set_cmdc@s(eZdZdd�Zdd�ZdS)zProfile.fake_codecCs(||_||_||_d|_dS)Nr)rD�co_linerFrE)rr�line�namer	r	r
r_s			zProfile.fake_code.__init__cCst|j|j|jf�S)N)�reprrDrUrF)rr	r	r
�__repr__eszProfile.fake_code.__repr__N)rrrrrYr	r	r	r
�	fake_code^srZc@seZdZdd�ZdS)zProfile.fake_framecCs||_||_dS)N)rCr@)r�codeZpriorr	r	r
ris	zProfile.fake_frame.__init__N)rrrrr	r	r	r
rBhsrBcCsa|jdd|�}|jr.|jd}nd}|j||�}|jd||d�dS)NZprofilerrrPr?)rZr rBr1)rrWr[rOr2r	r	r
r.ms	zProfile.simulate_callcCse|j}|�|j}x5|jdrP|jd||jd|�d}qW|�||_dS)NrrRrrrSr?)r&r-r r1)rr&r-r	r	r
�simulate_cmd_completeys	
zProfile.simulate_cmd_completercCs2ddl}|j|�j�j|�j�dS)Nr)�pstatsZStatsZ
strip_dirsZ
sort_statsr)rrr]r	r	r
r�szProfile.print_statsc
Cs:t|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)r\�snapshot_stats)rr	r	r
r`�s
zProfile.create_statsc	Cs�i|_x{|jj�D]j\}\}}}}}|j�}d}x|j�D]}||7}qSW|||||f|j|<qWdS)Nr)rcr�items�copy�values)	r�funcrHrIrJrKrLZncZcallcntr	r	r
rf�s	+zProfile.snapshot_statscCs(ddl}|j}|j|||�S)Nr)�__main__�__dict__r)rr!rk�dictr	r	r
r�s	zProfile.runcCsF|j|�tj|j�zt|||�Wdtjd�X|S)N)rT�sys�
setprofiler(�exec)rr!rrr	r	r
r�s
zProfile.runctxcOsI|jt|��tj|j�z|||�SWdtjd�XdS)N)rTrXrnror()rrj�args�kwr	r	r
�runcall�s
zProfile.runcallcCsR|jtk	rtd��|j}d|_z|j||�SWd||_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�}|dd�}||�|�}||�|�}||}|rgtd|�t�}	|�}|	jdt�t��|�}||}
|r�td|
�d}d}xU|	jj�D]D\\}
}}\}}}}}|dkr�||7}||7}q�W|r<td|�td|�||d
kr\td|��||d|}|r�td|�|S)NcSs!xt|�D]}d}q
WdS)Nr)�range)�n�i�xr	r	r
�f1�sz$Profile._calibrate_inner.<locals>.f1cSs%xt|�D]}|d�q
WdS)N�d)ry)rvr}r{r	r	r
re�sz#Profile._calibrate_inner.<locals>.fz elapsed time without profiling =zf(m)zelapsed time with profiling =grer}z!'CPU seconds' profiler reported =ztotal # calls =rz internal error: total calls = %dg@z+mean stopwatch overhead per profile event =)rer})	r&�printrrrrrrg�
ValueError)rrvrwr&r}re�t0�t1Zelapsed_noprofile�pZelapsed_profileZtotal_callsZ
reported_timerrV�funcnamerHrIrJrKrLZmeanr	r	r
ru�sB	
	
	

			

1



zProfile._calibrate_innerrS)rrrr#rr+r'r6r,r>rMrNr7r1rTrZrBr.r\rrr`rfrrrsrxrur	r	r	r
rhs<'''



1cCshd}td|�}d|_|jdddddd	d
d�|jdddd
ddd
d�tjdd�s�|j�tjd�|j�\}}|tjdd�<t|�dkrZ|d}tj	j
dtj	j|��t
|d��}t|j�|d�}WdQRXd|ddddddi}t||d|j|j�n
|j�|S)Nz?profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...�usageFz-oz	--outfile�dest�outfile�helpzSave stats to <outfile>�defaultz-sz--sortrz?Sort order when printing to stdout, based on pstats.Stats classrrr�rbrp�__file__rrk�__package__�
__cached__rS)rZallow_interspersed_argsZ
add_optionrn�argv�print_usage�exit�
parse_argsr)�path�insert�os�dirnamer_�compile�readrr�r)r��parser�optionsrqZprogname�fpr[Zglobsr	r	r
�main*s2	




r�rk)
rnr�r$raZoptparser�__all__rrrrr�rr	r	r	r
�<module>s
'
	��"