-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyc

ó
¦îNc@@s›ddlmZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddgZd„Z
defd	„ƒYZdefd
„ƒYZdefd„ƒYZiZed
„Zedkr—ddlZejde_ejs,ejjdƒejdƒnejjdejjejjejdƒƒƒe
eejdeƒe ƒƒZ!e!j"ƒe!j#ƒndS(i(tabsolute_importN(tProfilertprofiler_entry(terrorstprofiletStatscO@s@tƒ}|jƒz|||Ž}Wd|jƒ}X||fS(s†Run a function profile.

    Exceptions are not caught: If you need stats even when exceptions are to be
    raised, pass in a closure that will catch the exceptions and transform them
    appropriately for your driver function.

    Important caveat: only one profile can execute at a time. See BzrProfiler
    for details.

    :return: The functions return value and a stats object.
    N(tBzrProfilertstarttstop(tftargstkwdstprofilertrettstats((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRs	

RcB@s;eZdZdZejƒZd„Zd„Zd„Z	RS(sfBzr utility wrapper around Profiler.
    
    For most uses the module level 'profile()' function will be suitable.
    However profiling when a simple wrapped function isn't available may
    be easier to accomplish using this class.

    To use it, create a BzrProfiler and call start() on it. Some arbitrary
    time later call stop() to stop profiling and retrieve the statistics
    from the code executed in the interim.

    Note that profiling involves a threading.Lock around the actual profiling.
    This is needed because profiling involves global manipulation of the python
    interpreter state. As such you cannot perform multiple profiles at once.
    Trying to do so will lock out the second profiler unless the global 
    bzrlib.lsprof.BzrProfiler.profiler_block is set to 0. Setting it to 0 will
    cause profiling to fail rather than blocking.
    icC@s“i|_tƒ|_|jjj|jjƒ}|sKtjddƒ‚ny'|jj	dt
ƒtj|j
ƒWn|jjjƒ‚nXdS(sƒStart profiling.
        
        This hooks into threading and will record all calls made until
        stop() is called.
        tmsgsAlready profiling somethingtsubcallsN(t_g_threadmapRtpt	__class__t
profiler_locktacquiretprofiler_blockRtInternalBzrErrortenabletTruet	threadingt
setprofilet_thread_profiletrelease(tselft	permitted((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRAs	cC@sÇz¯|jjƒx!|jjƒD]}|jƒq Wtjdƒ|j}d|_i}x6|jjƒD]%\}}t|j	ƒiƒ||<qiWd|_t|j	ƒ|ƒSWd|j
jjƒXdS(s¶Stop profiling.

        This unhooks from threading and cleans up the profiler, returning
        the gathered Stats object.

        :return: A bzrlib.lsprof.Stats object.
        N(
RtdisableRtvaluesRRtNonetitemsRtgetstatsRRR(RtppRtthreadsttid((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRTs

			cO@s:tjƒ}tƒ|j|<}|jdtdtƒdS(NRtbuiltins(tthreadt	get_identRRRR(RR	R
RtthrR((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRks(
t__name__t
__module__t__doc__RRtLockRRRR(((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyR(s		cB@sPeZdZd„Zdd„Zddd„Zd„Zd„Zdd„Z	RS(	sðWrapper around the collected data.

    A Stats instance is created when the profiler finishes. Normal
    usage is to use save() to write out the data to a file, or pprint()
    to write human-readable information to the command line.
    cC@s||_||_dS(N(tdataR&(RR0R&((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyt__init__|s	t
inlinetimec@suˆtjkrtdˆ‚n|jj‡fd†ƒx6|jD]+}|jrB|jj‡fd†ƒqBqBWdS(seSort the data by the supplied critera.

        :param crit: the data attribute used as the sort key.sCan't sort by %sc@stt|ˆƒt|ˆƒƒS(N(tcmptgetattr(tbta(tcrit(s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyt<lambda>†sc@stt|ˆƒt|ˆƒƒS(N(R3R4(R5R6(R7(s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyR8ŠsN(Rt__dict__t
ValueErrorR0tsorttcalls(RR7te((R7s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyR;€s	c	C@s|d
krtj}n|j}|d
k	r:|| }nd}d}d}|j|dƒx |D]˜}|j||j|j|j|jt	|j
ƒfƒ|jrdxQ|jD]C}|j|d	|j|j|j|jd	t	|j
ƒfƒq²WqdqdWd
S(sPretty-print the data as plain text for human consumption.

        :param top: only output the top n entries.
            The default value of None means output all data.
        :param file: the output file; if None, output will
            default to stdout.s% 12s %12s %11.4f %11.4f   %s
s% 12s %12s %12s %12s %s
s+%12s %12s %11.4f %11.4f +  %s
t	CallCountt	Recursives	Total(ms)s
Inline(ms)smodule:lineno(function)s+%sN(R>R?s	Total(ms)s
Inline(ms)smodule:lineno(function)(R"tsyststdoutR0twritet	callcounttreccallcountt	totaltimeR2tlabeltcodeR<(	Rttoptfiletdtcolsthcolstcols2R=tse((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pytpprints$	
	
	cC@sxçtt|jƒƒD]Ð}|j|}t|jtƒskt|ƒt|jƒf|dƒ|j|<n|jrxott|jƒƒD]U}|j|}t|jtƒsŠt|ƒt|jƒf|dƒ|j|<qŠqŠWqqWx!|j	j
ƒD]}|jƒqúWdS(swReplace all references to code objects with string
        descriptions; this makes it possible to pickle the instance.iN(trangetlenR0t
isinstanceRGtstrttypeRFR<R&R!tfreeze(RtiR=tjRNts((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRU§s
0	
;cC@st|jƒj|ƒdS(s;Output profiling data in calltree format (for KCacheGrind).N(t_CallTreeFilterR0toutput(RRI((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pytcalltree¸scC@së|dkrntjj|ƒ}|jdƒr6d}qntjj|ƒd}t|ƒdkrn|d}qnnt|dƒ}z\|dkrœ|j|ƒn<|dkr»|j	d|ƒn|j
ƒtj||dƒWd|j
ƒXdS(	sâSave profiling data to a file.

        :param filename: the name of the output file
        :param format: 'txt' for a text representation;
            'callgrind' for calltree format;
            otherwise a pickled Python object. A format of None indicates
            that the format to use is to be found from the filename. If
            the name starts with callgrind.out, callgrind format is used
            otherwise the format is given by the filename extension.
        s
callgrind.outt	callgrinditwbttxtRIiN(R"tostpathtbasenamet
startswithtsplitextRQtopenR[RORUtcPickletdumptclose(RtfilenametformatRatexttoutfile((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pytsave¼s 	
N(
R,R-R.R1R;R"RORUR[Rl(((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRts	
		RYcB@s;eZdZd„Zd„Zd„Zd„Zd„ZRS(s„Converter of a Stats object to input suitable for KCacheGrind.

    This code is taken from http://ddaa.net/blog/python/lsprof-calltree
    with the changes made by J.P. Calderone and Itamar applied. Note that
    isinstance(code, str) needs to be used at times to determine if the code
    object is actually an external code object (with a filename, etc.) or
    a Python built-in.
    cC@s||_d|_dS(N(R0R"tout_file(RR0((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyR1æs	cC@sE||_|jdƒ|jƒx|jD]}|j|ƒq*WdS(Nsevents: Ticks
(RmRBt_print_summaryR0t_entry(RRmtentry((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRZês
	

cC@sWd}x3|jD](}t|jdƒ}t||ƒ}qW|jjd|fƒdS(Niièssummary: %d
(R0tintREtmaxRmRB(Rtmax_costRpRE((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRnñs
cC@s&|j}|j}t|jdƒ}t|tƒrD|jdƒn|jd|jfƒ|jdt|t	ƒfƒt|tƒrž|jd|fƒn|jd|j
|fƒ|jrÍ|j}ng}t|tƒrëd}n	|j
}x|D]}|j||ƒqûW|jdƒdS(	Nièsfi=~
sfi=%s
sfn=%s
s0  %s
s%d %d
is
(
RmRGRqR2RRRSRBtco_filenameRFRtco_firstlinenoR<t	_subentry(RRpRmRGR2R<tlinenotsubentry((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRoøs&					
cC@sä|j}|j}t|jdƒ}t|tƒrx|jdƒ|jdt|tƒfƒ|jd|j	fƒnQ|jd|j
fƒ|jdt|tƒfƒ|jd|j	|jfƒ|jd||fƒdS(Nièscfi=~
scfn=%s
scalls=%d 0
scfi=%s
scalls=%d %d
s%d %d
(RmRGRqRERRRSRBRFRRCRtRu(RRwRxRmRGRE((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRvs		
	(R,R-R.R1RZRnRoRv(((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRYÜs				cC@st|tƒr|Syt|j}Wn»tk
ráx«tjjƒD]~\}}|dkrbqDnt	|ddƒdkr€qDnt|j
tƒs˜qDn|j
j|jƒrD|}t|j<PqDqDWd|j}t|j<nX|rÿd|j||j
fSd||j
|jfSdS(Nt__file__s<%s>s%s %s:%ds	%s:%d(%s)(RRRSt_fn2modRttKeyErrorR@tmodulesR#R"R4RyRbtco_nameRu(RGR[tmnametktv((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyRF%s&
t__main__is)usage: lsprof.py <script> <arguments...>
i($t
__future__RReR_R@R)Rt_lsprofRRtbzrlibRt__all__RtobjectRRRYRztFalseRFR,targvtstderrRBtexitR`tinserttabspathtdirnametexecfiletglobalstlocalsRR;RO(((s1/usr/lib/python2.7/dist-packages/bzrlib/lsprof.pyt<module>s0	LhG	2"


Copyright © 2017 || Recoded By Mr.Bumblebee