mò %U²Ic@s\dZdkZdkZdkZdkZdgZdfd„ƒYZdfd„ƒYZd„Zd„Z d„Z d „Z d „Z d „Z d „Zed jo³dkZy dkZWnej onXdeifd„ƒYZdkZdGHeeiƒdjoeidZneZyeeƒiƒdGHWnej onXndS(s3Class for printing reports on profiled python code.NtStatscBsÓtZdZd„Zd„Zd„Zd„Zd„Zd„Zhddd ffd f<d d d ffd f<dddffdf<dddffdf<dddffdf<dddffdf<dddfddfddffdf<ddd ffd f<dddffdf<dd d ffd!fR#iR?Rs, (tfieldRR RRRLt sort_arg_defst sort_tuplet sort_typet connectorRIt stats_listRR6R,R-R.R/R0R1tappendR3tsortt TupleComptcomparettuple(RRMRIRWR-R.RNRQR1ROR,R RRR/R0((Rt sort_statsÊs0 09   1 cCs|io|iiƒn|S(N(RR treverse(R((Rt reverse_orderês cCs\|i} h|_}d} xç| iƒD]Ù\} \}}}} }t | ƒ}tt|ƒƒ| jott|ƒƒ} nh}x*|iƒD]\}}||t |ƒ ( tlisttnew_listRtselR,tretsearchR3RSRtcounttinttmsg(RRhRfRmRkRgR,((Rteval_print_amounts" 77'cCs|i}|io|i}d|id}n|iiƒ}d}x)|D]!}|i |||ƒ\}}qNWt |ƒ}|pd|fSn|GH|t |iƒjoJd}xA|D]5}t t|ƒƒ|jot t|ƒƒ}q¼q¼Wn|d|fS(Ns Ordered by: s s! Random listing order was used ii(RRtwidthR RfRPRmRtkeystsel_listt selectionRnRRkR,R3(RRqRkRrRfRoR,Rm((Rtget_print_list3s(    cGsáx|iD] }|GHq W|ioHndd}x |iD]}|Gt|ƒGHq<W|G|iGdG|i|ijod|iGnd|i GHH|i |ƒ\}}|o.|iƒx|D]}|i|ƒqÀWHHn|S(Nt isfunction callss(%d primitive calls)sin %.3f CPU seconds(RR R;tindentRR,tfunc_get_function_nameRRR RstamountRoRft print_titlet print_line(RRwRuRfR;RoR,((Rt print_statsKs.       cGs’|i|ƒ\}}|or|iƒ|i|dƒxO|D]G}||ijo|i |||i|ƒq=|i ||hƒq=WHHn|S(Ns called...( RRsRwRoRfRetprint_call_headingR,R tprint_call_line(RRwRoRfR,((Rt print_calleesas c Gsv|i|ƒ\}}|oV|i|dƒx=|D]5}|i|\}}}} }|i |||ƒq3WHHn|S(Nswas called by...(RRsRwRoRfR{R,RR-R.R/R0R1R|( RRwR-R.RfRoR1R,R/R0((Rt print_callerspscCsdi|ƒ|GHdS(Ns Function (tljustt name_sizet column_title(RR€R((RR{{scCs¥t|ƒi|ƒG|p dGHdSn|iƒ}|iƒ|d}d}xQ|D]I}t|ƒ}|||d||fGt |i |dƒGHd}qTWdS(Ns--iRs(%r)iRt(R3tsourceRR€t call_dictRptclistRTRuR,RBtf8RR(RR€R‚RƒRuRBR„R,((RR|~s    1cCs dGdGHdS(Ns- ncalls tottime percall cumtime percallsfilename:lineno(function)((R((RRxscCsË|i|\}}}}}t|ƒ}||jo|dt|ƒ}n|i dƒGt |ƒG|djo ddGnt ||ƒGt |ƒG|djo ddGnt ||ƒGt |ƒGHdS(Nt/i iRti( RRR,R-R.R/R0R1tstrtctrjustR…R3(RR,RˆR-R.R1R/R0((RRy‘s         cCsdS(N((R((Rtignore£s(t__name__t __module__t__doc__R RRRRR=RHRLRXRZRdReRnRsRzR}R~R{R|RxRyRŠ(((RR*s0     ÿ            RUcBs tZdZd„Zd„ZRS(s•This 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(tcomp_select_listR(RRŽ((RR ¯scCs]xV|iD]K\}}||}||}||jo | Sn||jo|Sq q WdS(Ni(RRŽtindext directiontlefttltrighttr(RR‘R“RRR’R”((RRV²s       (R‹RŒRR RV(((RRU§s  cCs(|\}}}tii|ƒ||fS(N(t func_nameR;R@RBR tpathtbasename(R•R@RBR;((RR]¿scCs|dS(Ni(R,(R,((RRvÃscCsd|S(Ns %s:%d(%s)(R•(R•((RR3Æsc CsV|\}}}} }|\} }}}} || ||||| |t | |ƒfS(s3Add together all the stats for two profile entries.N( R‚R-R.R/R0R1ttargettt_cctt_nctt_tttt_ctt t_callerst add_callers( R˜R‚R›R-R/R.RœRšR1RR™R0((RR8ÏscCs{h}x$|iƒD]\}}|||(R1R.R>((Rt count_callsâs  cCsd|S(Ns%8.3f(tx(R¢((RR…íst__main__tProfileBrowsercBsìtZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(NcCsFtii|ƒd|_|dj ot|ƒ|_n d|_dS(Ns% ( tcmdtCmdR RtprompttprofileRRR(RR¨((RR üs   cCsé|iƒ}g}x§|D]Ÿ}y|it|ƒƒwWntj onXyFt|ƒ}|djp |djo dGHwn|i|ƒwWntj onX|i|ƒqW|i ot |i |ƒ|ŒndGHdS(Niis"Fraction argument mus be in [0, 1]sNo statistics object is loaded.(R@tsplitRt processedttermRSRlt ValueErrortfloattfracRRtgetattrtfn(RR°R@R«R®RRª((Rtgenerics.    cCs"dGHdGHdGHdGHdGHdGHdS(NsArguments may be:s0* An integer maximum number of entries to print.s:* A decimal fractional number between 0 and 1, controllings- what fraction of selected entries to print.s8* A regular expression; only entries with function namess that match it are printed.((R((Rt generic_helps cCs|ii|ƒdS(Ni(RRRR@(RR@((Rtdo_add$scCs dGHdS(Ns>Add profile info from given file to current statistics object.((R((Rthelp_add'scCs|id|ƒS(NR}(RR±R@(RR@((Rt do_callees*scCsdGH|iƒdS(Ns6Print callees statistics from the current stat object.(RR²(R((Rt help_callees,scCs|id|ƒS(NR~(RR±R@(RR@((Rt do_callers0scCsdGH|iƒdS(Ns6Print callers statistics from the current stat object.(RR²(R((Rt help_callers2scCs dGHdS(NRi((RR@((Rtdo_EOF6scCs dGHdS(NsLeave the profile brower.((R((Rthelp_EOF9scCsdS(Ni((RR@((Rtdo_quit<scCs dGHdS(NsLeave the profile brower.((R((Rt help_quit>scCs€|oIyt|ƒ|_Wn"tj o}|dGHdSnX|d|_n-t|iƒdjo|id}ndGHdS(Nis% iiþÿÿÿs1No statistics object is current -- cannot reload.i(R@RRRtIOErrorRR§R(RR@R((Rtdo_readAs  cCs dGHdS(Ns+Read in profile data from a specified file.((R((Rt help_readNscCs|iiƒdS(Ni(RRRZ(RR@((Rt do_reverseQs cCs dGHdS(Ns/Reverse the sort order of the profiling report.((R((Rt help_reverseTscCs‰|iiƒ}|o7t|d„|iƒƒ o|ii|iƒŒn9dGHx0ti i ƒD]\}}d||dfGHqbWdS(NcCs ||jS(N(R¢ta(R¢RÂ((RtYss/Valid sort keys (unique prefixes are accepted):s%s -- %sii( RRRLtabbrevsR@tfilterR©RXRRHR6tkeytvalue(RR@RÄRÇRÆ((Rtdo_sortWs$ cCsdGHdGHdS(Ns.Sort profile data according to specified keys.s3(Typing `sort' without arguments lists valid keys.)((R((Rt help_sort`scGs6g}tiD]!}|i|ƒo ||qq~S(N(t_[1]RRHRÂt startswithttext(RRÌRRÂRÊ((Rt complete_sortcscCs|id|ƒS(NRz(RR±R@(RR@((Rtdo_statsfscCsdGH|iƒdS(Ns.Print statistics from the current stat object.(RR²(R((Rt help_statshscCs|iiƒdS(Ni(RRRd(RR@((Rtdo_stripls cCs dGHdS(Ns<Strip leading path information from filenames in the report.((R((Rt help_striposcCs|o|SndS(N(tstopR(RRÒR@((Rtpostcmdrs(R‹RŒRR R±R²R³R´RµR¶R·R¸R¹RºR»R¼R¾R¿RÀRÁRÈRÉRÍRÎRÏRÐRÑRÓ(((RR¤ûs2                      s*Welcome to the profile statistics browser.isGoodbye.(RR R#RRit__all__RRUR]RvR3R8RžR¡R…R‹R¥treadlinet ImportErrorR¦R¤tsysRtargvt initprofileRtcmdlooptKeyboardInterrupt(R¥RR…R8RÔR]RiRžRURvRÙR×R¡RÕR¤R#R RR3((Rt?s@"     ÿ~       |