%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/profile.pyc

ó
Męáac@s$dZddlZddlZddlZddlZddlmZddddgZedd„Z	edd	„Z
d
„Zeedƒr ej
d„Znd
Zy+ddlZd„Zed„ZdZWnek
ränXdfd„ƒYZd„Zd„Zedkr eƒndS(s Class for profiling Python code.i˙˙˙˙N(tOptionParsertruntrunctxthelptProfilecCs]tƒ}y|j|ƒ}Wntk
r/nX|dk	rL|j|ƒn
|j|ƒSdS(sRun statement under profiler optionally saving results in filename

    This function takes a single argument that can be passed to the
    "exec" statement, and an optional file name.  In all cases this
    routine attempts to "exec" its first argument and gather profiling
    statistics from the execution. If no file name is present, then this
    function automatically prints a simple profiling report, sorted by the
    standard name string (file/line/function-name) that is presented in
    each line.
    N(RRt
SystemExittNonet
dump_statstprint_stats(t	statementtfilenametsorttprof((s#/usr/local/lib/python2.7/profile.pyR0s	
cCsctƒ}y|j|||ƒ}Wntk
r5nX|dk	rR|j|ƒn
|j|ƒSdS(sˇRun statement under profiler, supplying your own globals and locals,
    optionally saving results in filename.

    statement and filename have the same semantics as profile.run
    N(RRRRRR(R	tglobalstlocalsR
RR((s#/usr/local/lib/python2.7/profile.pyREs	
cCsdGHdGHdS(Ns2Documentation for the profile module can be found s?in the Python Library Reference, section 'The Python Profiler'.((((s#/usr/local/lib/python2.7/profile.pyRWsttimescCs|ƒ}|d|dS(Nii((ttimertt((s#/usr/local/lib/python2.7/profile.pyt_get_time_times\s	icCstjtjƒS(N(tresourcet	getrusagetRUSAGE_SELF(((s#/usr/local/lib/python2.7/profile.pyt<lambda>gtcCs|ƒ}|d|dS(Nii((RR((s#/usr/local/lib/python2.7/profile.pyt_get_time_resourcehs	icBs3eZdZdZd"d"d„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
ied6e
d6e
d
6ed6e
d6e
d6Zd„Zdd#d„ƒYZdd$d„ƒYZd„Zd„Zdd„Zd„Zd„Zd„Zd„Zd„Zd„Zdd „Zd!„ZRS(%sProfiler class.

    self.cur is always a tuple.  Each such tuple corresponds to a stack
    frame that is currently active (self.cur[-2]).  The following are the
    definitions of its members.  We use this external "parallel stack" to
    avoid contaminating the program that we are profiling. (old profiler
    used to write into the frames local dictionary!!) Derived classes
    can change the definition of some entries, as long as they leave
    [-2:] intact (frame and previous tuple).  In case an internal error is
    detected, the -3 element is used as the function name.

    [ 0] = Time that needs to be charged to the parent frame's function.
           It is used so that a function call will not have to access the
           timing data for the parent frame.
    [ 1] = Total time spent in this frame's function, excluding time in
           subfunctions (this latter is tallied in cur[2]).
    [ 2] = Total time spent in subfunctions, excluding time executing the
           frame's function (this latter is tallied in cur[1]).
    [-3] = Name of the function that corresponds to this frame.
    [-2] = Actual frame that we correspond to (used to sync exception handling).
    [-1] = Our parent 6-tuple (corresponds to frame.f_back).

    Timing data for each function is stored as a 5-tuple in the dictionary
    self.timings[].  The index is always the name stored in self.cur[-3].
    The following are the definitions of the members:

    [0] = The number of times this function was called, not counting direct
          or indirect recursion,
    [1] = Number of times this function appears on the stack, minus one
    [2] = Total time spent internal to this function
    [3] = Cumulative time that this function was present on the stack.  In
          non-recursive functions, this is the total execution time from start
          to finish of each invocation of a function, including time spent in
          all subfunctions.
    [4] = A dictionary indicating for each function name, the number of times
          it was called by us.
    icCsĽi|_d|_d|_d|_|dkr<|j}n||_|sřtrrt|_|j	|_
t|_q…t
tdƒrŁtj|_|_|j|_
q…t
tdƒrÖtj|_|j	|_
t|_q…tj|_|_|j|_
n||_|jƒ}yt|ƒ}Wn&tk
rE||_|j|_
n@X|dkra|j	|_
n|j|_
|td„}||_|jƒ|_|jdƒdS(NRtclockRicSs
||ƒƒS(N((Rtsum((s#/usr/local/lib/python2.7/profile.pytget_time_timerĂstprofiler(ttimingsRtcurtcmdtc_func_nametbiast_has_restresgetrusageRttrace_dispatcht
dispatcherRtget_timethasattrttimeRttrace_dispatch_itosRRtlent	TypeErrorttrace_dispatch_lRRt
simulate_call(tselfRR!RtlengthR((s#/usr/local/lib/python2.7/profile.pyt__init__˜sF							
		cCs­|j}|ƒ}|d|d|j|j}|dkrM|j|_n|j||||ƒr‡|ƒ}|d|d|_n"|ƒ}|d|d||_dS(Niitc_call(RRR!t__name__R tdispatch(R/tframeteventtargRRtr((s#/usr/local/lib/python2.7/profile.pyR$Ës		 		cCsw|j}|ƒ|j|j}|dkr;|j|_n|j||||ƒrc|ƒ|_n|ƒ||_dS(NR2(RRR!R3R R4(R/R5R6R7RR((s#/usr/local/lib/python2.7/profile.pyR)Ýs	cCsƒ|j}|ƒd|j|j}|dkr?|j|_n|j||||ƒrk|ƒd|_n|ƒd||_dS(NgN@R2(RRR!R3R R4(R/R5R6R7RR((s#/usr/local/lib/python2.7/profile.pyttrace_dispatch_macěs	cCsw|j}|ƒ|j|j}|dkr;|j|_n|j||||ƒrc|ƒ|_n|ƒ||_dS(NR2(R&RR!R3R R4(R/R5R6R7R&R((s#/usr/local/lib/python2.7/profile.pyR-ús	c	Cs`|j\}}}}}}||k	r=|r=|j||ƒS|||||||f|_dS(Ni(Rttrace_dispatch_return(	R/R5Rtrpttrittrettrfntrframetrcur((s#/usr/local/lib/python2.7/profile.pyttrace_dispatch_exception
s
cCs€|jrÖ|j|jdk	rÖ|j\}}}}}}t|tjƒsÖ|j|jks‚td|||j||jfƒ‚|j|dƒ|jdksÓ|j|jdksÓtd|jdfƒ‚qÖn|j}	|	j	|	j
|	jf}
|dd|
||jf|_|j}|
|krc||
\}}
}}}||
d|||f||
<nddddif||
<dS(Niţ˙˙˙sBad calliiý˙˙˙i(
Rtf_backt
isinstanceRt
fake_frametAssertionErrorR:Rtf_codetco_filenametco_firstlinenotco_nameR(R/R5RR;R<R=R>R?R@tfcodetfnRtcctnsttttcttcallers((s#/usr/local/lib/python2.7/profile.pyttrace_dispatch_calls&			 c
Cs›dd|jf}|dd|||jf|_|j}||kr~||\}}}}}	||d|||	f||<nddddif||<dS(NRii(R RR(
R/R5RRKRRLRMRNRORP((s#/usr/local/lib/python2.7/profile.pyttrace_dispatch_c_call+s	 cCsU||jdk	r\||jdjksBtd|jdfƒ‚|j|jddƒn|j\}}}}}}||}||}|\}	}
}}}
}|	|
|||||
|f|_|j}||\}}}}}|s||}|d}n||kr&||d||<n
d||<||d||||f||<dS(Niţ˙˙˙s
Bad returniý˙˙˙ii(RRBRER:R(R/R5RR;R<R=R>R@tframe_totaltppttpittpettpfntpframetpcurRRLRMRNRORP((s#/usr/local/lib/python2.7/profile.pyR:6s$/

#	


!tcallt	exceptiontreturnR2tc_exceptiontc_returncCs+|jdrdS||_|j|ƒdS(Ni˙˙˙˙(RRR.(R/R((s#/usr/local/lib/python2.7/profile.pytset_cmdls
	t	fake_codecBseZd„Zd„ZRS(cCs(||_||_||_d|_dS(Ni(RGtco_lineRIRH(R/R
tlinetname((s#/usr/local/lib/python2.7/profile.pyR1rs			cCst|j|j|jfƒS(N(treprRGRaRI(R/((s#/usr/local/lib/python2.7/profile.pyt__repr__xs(R3t
__module__R1Re(((s#/usr/local/lib/python2.7/profile.pyR`qs	RDcBseZd„ZRS(cCs||_||_dS(N(RFRB(R/tcodetprior((s#/usr/local/lib/python2.7/profile.pyR1|s	(R3RfR1(((s#/usr/local/lib/python2.7/profile.pyRD{scCsa|jdd|ƒ}|jr.|jd}nd}|j||ƒ}|jd||dƒdS(Ntprofileiiţ˙˙˙RZ(R`RRRDR4(R/RcRgRXR5((s#/usr/local/lib/python2.7/profile.pyR.€s	cCse|j}|ƒ|j}x5|jdrP|jd||jd|ƒd}qW|ƒ||_dS(Ni˙˙˙˙R\iţ˙˙˙i(R&RRR4(R/R&R((s#/usr/local/lib/python2.7/profile.pytsimulate_cmd_completeŒs	
i˙˙˙˙cCs2ddl}|j|ƒjƒj|ƒjƒdS(Ni˙˙˙˙(tpstatstStatst
strip_dirst
sort_statsR(R/RRk((s#/usr/local/lib/python2.7/profile.pyR—scCs:t|dƒ}|jƒtj|j|ƒ|jƒdS(Ntwb(topentcreate_statstmarshaltdumptstatstclose(R/tfiletf((s#/usr/local/lib/python2.7/profile.pyRœs
cCs|jƒ|jƒdS(N(Rjtsnapshot_stats(R/((s#/usr/local/lib/python2.7/profile.pyRq˘s
c	Cs‹i|_x{|jjƒD]j\}\}}}}}|jƒ}d}x|jƒD]}||7}qSW|||||f|j|<qWdS(Ni(RtRt	iteritemstcopyt
itervalues(	R/tfuncRLRMRNRORPtnctcallcnt((s#/usr/local/lib/python2.7/profile.pyRxŚs	+cCs(ddl}|j}|j|||ƒS(Ni˙˙˙˙(t__main__t__dict__R(R/RRtdict((s#/usr/local/lib/python2.7/profile.pyRłs	cBs@|j|ƒej|jƒz|||UWdejdƒX|S(N(R_tsyst
setprofileR%R(R/RR
R((s#/usr/local/lib/python2.7/profile.pyR¸s
cOsI|jt|ƒƒtj|jƒz|||ŽSWdtjdƒXdS(N(R_RdR‚RƒR%R(R/R|targstkw((s#/usr/local/lib/python2.7/profile.pytruncallÂs
cCsU|jtk	rtdƒ‚n|j}d|_z|j||ƒSWd||_XdS(Ns&Subclasses must override .calibrate().i(t	__class__RR,R!t_calibrate_inner(R/tmtverboset
saved_bias((s#/usr/local/lib/python2.7/profile.pyt	calibrateós		cCs}|j}d„}|d„}||ƒ|ƒ}||ƒ|ƒ}||}|r`dG|GHntƒ}	|ƒ}|	jdtƒtƒƒ|ƒ}||}
|r°dG|
GHnd}d}xX|	jjƒD]G\\}
}}\}}}}}|dkrĚ||7}||7}qĚqĚW|r2d	G|GHd
G|GHn||dkrUtd|ƒ‚n||d
|}|rydG|GHn|S(NcSs!xt|ƒD]}d}q
WdS(Ni(trange(tntitx((s#/usr/local/lib/python2.7/profile.pytf1scSs%xt|ƒD]}|dƒq
WdS(Nid(R(R‰R‘R((s#/usr/local/lib/python2.7/profile.pyRwss elapsed time without profiling =sf(m)selapsed time with profiling =gRwR‘s!'CPU seconds' profiler reported =stotal # calls =is internal error: total calls = %dg@s+mean stopwatch overhead per profile event =(RwR‘(R&RRR
RRtitemst
ValueError(R/R‰RŠR&R‘Rwtt0tt1telapsed_noprofiletptelapsed_profilettotal_callst
reported_timeR
RbtfuncnameRLRMRNRORPtmean((s#/usr/local/lib/python2.7/profile.pyRˆţsB		
	
	
			
1
	N(((R3Rft__doc__R!RR1R$R)R9R-RARQRRR:R4R_R`RDR.RjRRRqRxRRR†RŒRˆ(((s#/usr/local/lib/python2.7/profile.pyRos@%3								&

	
					
		
	1cGs	dGHdS(Ns7Report generating functions are in the "pstats" module((R„((s#/usr/local/lib/python2.7/profile.pyRl=sc	CsXd}td|ƒ}t|_|jddddddd	dƒ|jd
ddddd
d	dƒtjds‰|jƒtjdƒn|j	ƒ\}}|tj(t
|ƒdkrJ|d}tjjdt
jj|ƒƒt|dƒ}t|jƒ|dƒ}WdQXi|d6dd6dd6}t||d|j|jƒn
|jƒ|S(Ns?profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...tusages-os	--outfiletdesttoutfileRsSave stats to <outfile>tdefaults-ss--sortRs?Sort order when printing to stdout, based on pstats.Stats classi˙˙˙˙iiitrbtexect__file__RR3t__package__(RtFalsetallow_interspersed_argst
add_optionRR‚targvtprint_usagetexitt
parse_argsR+tpathtinsertR*tdirnameRptcompiletreadRR R(RžtparsertoptionsR„tprognametfpRgtglobs((s#/usr/local/lib/python2.7/profile.pytmain@s2	






R(RR‚R*R(RrtoptparseRt__all__RRRRR'RRR"RR#RtImportErrorRRlRˇR3(((s#/usr/local/lib/python2.7/profile.pyt<module>	s2		

˙Ď		!

Zerion Mini Shell 1.0