MINI MINI MANI MO

Path : /usr/lib64/python3.6/__pycache__/
File Upload :
Current File : //usr/lib64/python3.6/__pycache__/pstats.cpython-36.pyc

3


 \g@sfdZddlZddlZddlZddlZddlZddlmZdgZGdddZ	GdddZ
dd	Zd
dZdd
Z
ddZddZddZddZedkrbddlZyddlZWnek
rYnXGdddejZeejdkrejdZndZyTeeZx"ejddD]ZejeqWedejdej edejdWne!k
r`YnXdS)z3Class for printing reports on profiled python code.N)
cmp_to_keyStatsc@seZdZdZddddZddZdd	Zd
dZdd
ZddZ	dBdFdJdNdQdTdWdZd]dbdfdidmdqd!Z
d"d#Zd$d%Zd&d'Z
d(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zdrd9d:Zd;d<Zd=d>ZdS)sraThis class is used for creating reports from data generated by the
    Profile class.  It is a "friend" of that class, and imports data either
    by direct access to members of Profile class, or by reading in a dictionary
    that was emitted (via marshal) from the Profile class.

    The big change from the previous Profiler (in terms of raw functionality)
    is that an "add()" method has been provided to combine Stats from
    several distinct profile runs.  Both the constructor and the add()
    method now take arbitrarily many file names as arguments.

    All the print methods now take an argument that indicates how many lines
    to print.  If the arg is a floating point number between 0 and 1.0, then
    it is taken as a decimal percentage of the available lines to be printed
    (e.g., .1 means print 10% of all available lines).  If it is an integer,
    it is taken to mean the number of lines of data that you wish to have
    printed.

    The sort_stats() method now processes some additional options (i.e., in
    addition to the old -1, 0, 1, or 2 that are respectively interpreted as
    'stdname', 'calls', 'time', and 'cumulative').  It takes an arbitrary number
    of quoted strings to select the sort order.

    For example sort_stats('time', 'name') sorts on the major key of 'internal
    function time', and on the minor key of 'the name of the function'.  Look at
    the two tables in sort_stats() and get_sort_arg_defs(self) for more
    examples.

    All methods return self, so you can string together commands like:
        Stats('foo', 'goo').strip_dirs().sort_stats('calls').                            print_stats(5).print_callers(5)
    N)streamcGsF|ptj|_t|sd}n|d}|dd}|j||j|dS)Nr)sysstdoutrleninitadd)selfrargsargr/usr/lib64/python3.6/pstats.py__init__As
zStats.__init__cCsd|_g|_d|_d|_d|_d|_d|_t|_i|_	i|_
|j|y|jWn8t
k
rtd|jrx|jdnd|jdYnXdS)NrzInvalid timing data %sr)file)all_calleesfilesfcn_listtotal_tttotal_calls
prim_callsmax_name_lenset	top_levelstats
sort_arg_dict
load_statsget_top_level_stats	Exceptionprintr)rr
rrrr	Ks"
z
Stats.initcCs|dkri|_dSt|trxt|d}tj||_WdQRXy"tj|}tj	|j
d|}WnYnX|g|_n t|dr|j
|j|_i|_|jstd|j|fdS)Nrbz    create_statsz.Cannot create or construct a %r object from %r)r
isinstancestropenmarshalloadosstattimeZctimest_mtimerhasattrr$	TypeError	__class__)rr
fZ
file_statsrrrr^s(



zStats.load_statscCsx~|jjD]p\}\}}}}}|j|7_|j|7_|j|7_d|kr\|jj|tt||j	krtt||_	qWdS)Njprofilerprofiler)r2rr3)
ritemsrrrrr
rfunc_std_stringr)rfuncccncttctcallersrrrr tszStats.get_top_level_statscGs|s|Sxt|D]}t|t|kr.t|}|j|j7_|j|j7_|j|j7_|j|j7_x|jD]}|jj|qvW|j	|j	kr|j	|_	d|_
xJ|jjD]<\}}||jkr|j|}nddddif}t
|||j|<qWqW|S)Nr)reversedtyperrrrrrr
rrrr4add_func_stats)rarg_listitemr6r+Z
old_func_statrrrr
~s(
z	Stats.addc
Cs(t|d}tj|j|WdQRXdS)z:Write the profile data to a file we know how to load back.wbN)r'r(dumpr)rfilenamer1rrr
dump_statsszStats.dump_statsr
call countcumulative time	file nameline number
function namename/file/linerprimitive call count
standard name
internal time)callsZncallsZcumtime
cumulativerrClinemodulenameZnflZpcallsstdnamer,ZtottimecCs|jszi|_}i}xP|jjD]B\}}|}x4|r`|s8P||krJd||<P|||<|dd}q.Wq Wx|D]
}||=qlW|jS)z)Expand all abbreviations that are unique.rNrr)rsort_arg_dict_defaultr4)rdictZbad_listwordtupZfragmentrrrget_sort_arg_defss 


zStats.get_sort_arg_defscGs"|sd|_|St|dkrFt|dtrFddddddddi|dg}|j}f}d|_d}x:|D]2}|||d}|j|||d7_d	}qbWg}xB|jjD]4\}\}}	}
}}|j||	|
|f|t	||fqW|j
tt|j
d
g|_}
x|D]}|
j|dqW|S)
NrrrYrTr,rRrUrz, )keyrr)rrr%intr^	sort_typerr4appendr5sortr	TupleCompcompare)rZfieldZ
sort_arg_defsZ
sort_tupleZ	connectorr\Z
stats_listr6r7r8r9r:r;rtuplerrr
sort_statss2


zStats.sort_statscCs|jr|jj|S)N)rreverse)rrrr
reverse_orders
zStats.reverse_ordercCs|j}i|_}d}x|jD]\}\}}}}}	t|}
tt|
|krTtt|
}i}x |	jD]\}}
|
|t|<qbW|
|krt||
|||||f||
<q|||||f||
<qW|j}t|_}x|D]}|jt|qW||_	d|_
d|_|S)Nr)rr4func_strip_pathrr5r>rrr
rrr)rZoldstatsZnewstatsrr6r7r8r9r:r;ZnewfuncZ
newcallersfunc2callerZold_topZnew_toprrr
strip_dirss.

zStats.strip_dirsc
Cs||jr
dSi|_}xb|jjD]T\}\}}}}}||krBi||<x0|jD]$\}}	||krdi||<|	|||<qLWq WdS)N)rrr4)
rrr6r7r8r9r:r;rkrlrrrcalc_calleess
zStats.calc_calleesc
Cs|}t|trpytj|}Wn&tjk
rB|d|7}||fSXg}x|D]}|jt|rN|j|qNWnzt|}t|t	rd|kodknrt
||d}|d|}n2t|t
rd|ko|knr|}|d|}t|t|kr|dt|t||f7}||fS)Nz#   <Invalid regular expression %r>
gg?g?rz6   List reduced from %r to %r due to restriction <%r>
)r%r&recompileerrorsearchr5rbrfloatr`)rZsellistmsgZnew_listZrexr6countrrreval_print_amounts,


""zStats.eval_print_amountcCs|j}|jr*|jdd}d|jd}nt|jj}d}x|D]}|j|||\}}qBWt|}|spd|fSt||j	d|t|jkrd}x(|D] }tt
||krtt
|}qW|d|fS)Nz   Ordered by: 
z!   Random listing order was used
r)rrR)rrrartrkeysrwrr"rr5)rZsel_listwidthZ	stat_listruZ	selectionrvr6rrrget_print_list2s$

zStats.get_print_listcGsx|jD]}t||jdqW|jr0t|jdd}x"|jD]}t|t||jdq<Wt||jdd|jd|j|jkrtd|jd|jdtd|j|jdt|jd|j|\}}|r|j	x|D]}|j
|qWt|jdt|jd|S)	N)r zfunction calls)endrz(%d primitive calls)zin %.3f secondsz        )rr"rrfunc_get_function_namerrrr{print_title
print_line)ramountrCindentr6rzrtrrrprint_statsJs(
zStats.print_statscGs~|j|\}}|rz|j|j|dx:|D]2}||jkrP|j|||j|q,|j||iq,Wt|jdt|jd|S)Nz	called...)r)r{rnprint_call_headingrprint_call_liner"r)rrrzrtr6rrr
print_calleesas

zStats.print_calleesc
Gsl|j|\}}|rh|j|dx0|D](}|j|\}}}}}	|j|||	dq$Wt|jdt|jd|S)Nzwas called by...z<-)r)r{rrrr"r)
rrrzrtr6r7r8r9r:r;rrr
print_callersps
zStats.print_callersc
Csxtdj|||jdd}x<|jjD].\}}}}}|r(tt|j}	t|	t}Pq(W|rttd|d|jddS)Nz	Function )rFr|z    ncalls  tottime  cumtime)	r"ljustrrvaluesnextiterr%rf)
r	name_sizeZcolumn_titleZ	subheaderr7r8r9r:r;valuerrrr{s
zStats.print_call_heading->cCstt|j||d|jd|s2t|jddSt|j}d}x|D]}t|}||}	t|	tr|	\}
}}}
|
|krd|
|f}n
d|
f}d|jdd	t	|t
|t
|
|f}|d
}n$d||	t
|j|df}|d}t||||jdd}qHWdS)
Nr|)r~r)rrz%d/%dz%dz%s %s %s  %srPrRrz	%s(%r) %srF)r"r5rrsortedryr%rfrjustrf8r)rrsourceZ	call_dictZarrowZclistrr6rXrr8r7r9r:ZsubstatsZ
left_widthrrrrs*



zStats.print_call_linecCs"tdd|jdtd|jddS)Nz-   ncalls  tottime  percall  cumtime  percallr|)r~rzfilename:lineno(function))r)r"r)rrrrrszStats.print_titlecCs|j|\}}}}}t|}||kr4|dt|}t|jdd|jdtt|d|jd|dkrxtdd|jdntt||d|jdtt|d|jd|dkrtd	d|jdntt||d|jdtt||jddS)
N/	r|)r~rrr})rz        z        )rr&r"rrrr5)rr6r7r8r9r:r;crrrrszStats.print_linerrrr)rrErrrr)rrErrFrr)rrGrrFrr)rrGrHrr)rrIrHrr)rrIrJrr)rrKrHrr)rrIrLrr)rrMrLrrHrrJrrrr)rrNrrrr)rrOrPrr)rrQrrRrr)rrSrrRrr)rrS)r)__name__
__module____qualname____doc__rr	rr r
rDrZr^rgrirmrnrwr{rrrrrrrrrrrr sF

 
c@s eZdZdZddZddZdS)rdaThis class provides a generic function for comparing any two tuples.
    Each instance records a list of tuple-indices (from most significant
    to least significant), and sort direction (ascending or decending) for
    each tuple-index.  The compare functions can then be used as the function
    argument to the system sort() function when a list of tuples need to be
    sorted in the instances order.cCs
||_dS)N)comp_select_list)rrrrrrszTupleComp.__init__cCsBx<|jD]2\}}||}||}||kr.|S||kr|SqWdS)Nr)r)rleftrightindex	directionlrrrrreszTupleComp.compareN)rrrrrrerrrrrdsrdcCs|\}}}tjj|||fS)N)r*pathbasename)	func_namerCrVrXrrrrjs
rjcCs|dS)NrRr)r6rrrrsrcCsN|ddd	krB|d}|jdr<|jdr<d|dd
S|Snd|SdS)NrR~r<>z{%s}rz	%s:%d(%s))rrr)
startswithendswith)rrXrrrr5sr5cCs@|\}}}}}|\}}}	}
}||||||	||
t||fS)z3Add together all the stats for two profile entries.)add_callers)targetrr7r8r9r:r;Zt_ccZt_ncZt_ttZt_ctZ	t_callersrrrr>sr>cCsi}x|jD]\}}|||<qWxb|jD]V\}}||krzt|trhtddt|||D||<q|||7<q,|||<q,W|S)z*Combine two caller lists in a single list.cSsg|]}|d|dqS)rrr).0irrr
<listcomp>szadd_callers.<locals>.<listcomp>)r4r%rfzip)rrZnew_callersr6rlrrrrs
rcCs"d}x|jD]}||7}qW|S)z@Sum the caller statistics to get total number of calls received.r)r)r;r8rTrrrcount_callssrcCsd|S)Nz%8.3fr)xrrrrsr__main__c@seZdZd6ddZddZddZdd	Zd
dZdd
ZddZ	ddZ
ddZddZddZ
ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5ZdS)7ProfileBrowserNcCs6tjj|d|_d|_tj|_|dk	r2|j|dS)Nz% )	cmdCmdrpromptrrrrdo_read)rprofilerrrrszProfileBrowser.__init__cCs|j}g}x|D]}y|jt|wWntk
r>YnXy8t|}|dksZ|dkrjtd|jdw|j|wWntk
rYnX|j|qW|jrt|j||ntd|jddS)Nrrz#Fraction argument must be in [0, 1])rzNo statistics object is loaded.)	splitrbr`
ValueErrorrsr"rrgetattr)rfnrVrZ	processedZtermZfracrrrgeneric"s,

zProfileBrowser.genericcCsXtd|jdtd|jdtd|jdtd|jdtd|jdtd|jddS)NzArguments may be:)rz0* An integer maximum number of entries to print.z:* A decimal fractional number between 0 and 1, controllingz-  what fraction of selected entries to print.z8* A regular expression; only entries with function namesz  that match it are printed.)r"r)rrrrgeneric_help:szProfileBrowser.generic_helpcCsd|jrRy|jj|Wq`tk
rN}ztd||f|jdWYdd}~Xq`Xntd|jddS)Nz$Failed to load statistics for %s: %s)rzNo statistics object is loaded.r)rr
IOErrorr"r)rrVerrrdo_addBs*zProfileBrowser.do_addcCstd|jddS)Nz>Add profile info from given file to current statistics object.)r)r"r)rrrrhelp_addKszProfileBrowser.help_addcCs|jd|S)Nr)r)rrVrrr
do_calleesNszProfileBrowser.do_calleescCstd|jd|jdS)Nz6Print callees statistics from the current stat object.)r)r"rr)rrrrhelp_calleesPszProfileBrowser.help_calleescCs|jd|S)Nr)r)rrVrrr
do_callersTszProfileBrowser.do_callerscCstd|jd|jdS)Nz6Print callers statistics from the current stat object.)r)r"rr)rrrrhelp_callersVszProfileBrowser.help_callerscCstd|jddS)Nr)rr)r"r)rrVrrrdo_EOFZszProfileBrowser.do_EOFcCstd|jddS)NzLeave the profile brower.)r)r"r)rrrrhelp_EOF]szProfileBrowser.help_EOFcCsdS)Nrr)rrVrrrdo_quit`szProfileBrowser.do_quitcCstd|jddS)NzLeave the profile brower.)r)r"r)rrrr	help_quitbszProfileBrowser.help_quitcCs|ryt||_Wnjtk
rF}zt|jd|jddSd}~Xn8tk
r|}zt|jjd||jddSd}~XnX|d|_	n6t
|j	dkr|j	dd}|j|ntd|jddS)	Nr)r:z% rRz1No statistics object is current -- cannot reload.r)rrOSErrorr"rrr!r0rrrr)rrVerrrrrreszProfileBrowser.do_readcCs td|jdtd|jddS)Nz+Read in profile data from a specified file.)rz*Without argument, reload the current file.)r"r)rrrr	help_readvszProfileBrowser.help_readcCs$|jr|jjntd|jddS)NzNo statistics object is loaded.)rr)rrir"r)rrVrrr
do_reversezszProfileBrowser.do_reversecCstd|jddS)Nz/Reverse the sort order of the profiling report.)r)r"r)rrrrhelp_reverseszProfileBrowser.help_reversecs|jstd|jddS|jj|rRtfdd|jDrR|jj|jn@td|jdx0tjj	D]"\}}td||df|jdqlWdS)	NzNo statistics object is loaded.)rc3s|]}|kVqdS)Nr)rr)abbrevsrr	<genexpr>sz)ProfileBrowser.do_sort.<locals>.<genexpr>z/Valid sort keys (unique prefixes are accepted):z%s -- %srr)
rr"rr^allrrgrrZr4)rrVr_rr)rrdo_sorts
zProfileBrowser.do_sortcCs td|jdtd|jddS)Nz.Sort profile data according to specified keys.)rz3(Typing `sort' without arguments lists valid keys.))r"r)rrrr	help_sortszProfileBrowser.help_sortcsfddtjDS)Ncsg|]}|jr|qSr)r)ra)textrrrsz0ProfileBrowser.complete_sort.<locals>.<listcomp>)rrZ)rrrr)rr
complete_sortszProfileBrowser.complete_sortcCs|jd|S)Nr)r)rrVrrrdo_statsszProfileBrowser.do_statscCstd|jd|jdS)Nz.Print statistics from the current stat object.)r)r"rr)rrrr
help_statsszProfileBrowser.help_statscCs$|jr|jjntd|jddS)NzNo statistics object is loaded.)r)rrmr"r)rrVrrrdo_stripszProfileBrowser.do_stripcCstd|jddS)Nz<Strip leading path information from filenames in the report.)r)r"r)rrrr
help_stripszProfileBrowser.help_stripcCstd|jddS)NzShow help for a given command.)r)r"r)rrrr	help_helpszProfileBrowser.help_helpcCs|r|SdS)Nr)rstoprVrrrpostcmdszProfileBrowser.postcmd)N)rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrs4
	rrrRz*Welcome to the profile statistics browser.)rzGoodbye.)"rrr*r,r(ro	functoolsr__all__rrdrjrr5r>rrrrrreadlineImportErrorrrrargvZinitprofileZbrowserrrr"rZcmdloopKeyboardInterruptrrrr<module>sN


OHA YOOOO