Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
 lŽŒYÄgã@sÚdZddlZddlZddlZddlZddlZddlmZdgZGdd„dƒZ Gdd„dƒZ dd „Z d d „Z d d „Z dd„Zdd„Zdd„Zdd„ZedkrÖddlZyddlZWnek rYnXGdd„dejƒZeejƒdkrPejdZndZykeeƒZx(ejdd…D]ZejeƒqyWeddejƒej ƒeddejƒWne!k rÕYnXdS)z3Class for printing reports on profiled python code.éN)Ú cmp_to_keyÚStatsc@sieZdZdZdddd„Zdd„Zdd „Zd d „Zd d „Zdd„Z ddOddSddWdd[dd^ddadddddgd djd#dod%dsd(dvd+dzd.d~iZ d/d0„Z d1d2„Z d3d4„Z d5d6„Zd7d8„Zd9d:„Zd;d<„Zd=d>„Zd?d@„ZdAdB„ZdCdD„ZdEdFdG„ZdHdI„ZdJdK„ZdS)ra–This 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) ÚstreamNcGs_|p tj|_t|ƒs'd}n|d}|dd…}|j|ƒ|j|ŒdS)Nré)ÚsysÚstdoutrÚlenÚinitÚadd)ÚselfrÚargsÚarg©rú%/opt/python35/lib/python3.5/pstats.pyÚ__init__As    zStats.__init__c CsÁd|_g|_d|_d|_d|_d|_d|_tƒ|_i|_ i|_ |j |ƒy|j ƒWnBt k r¼td|jr¤|jdndd|jƒ‚YnXdS)NrzInvalid timing data %srÚÚfileéÿÿÿÿ)Ú all_calleesÚfilesÚfcn_listÚtotal_ttÚ total_callsÚ prim_callsÚ max_name_lenÚsetÚ top_levelÚstatsÚ sort_arg_dictÚ load_statsÚget_top_level_statsÚ ExceptionÚprintr)r r rrrr Ks"            'z Stats.initcCsî|dkri|_dSt|tƒršt|dƒ�}tj|ƒ|_WdQRXy-tj|ƒ}tj |j ƒd|}WnYnX|g|_ n.t |dƒrÈ|j ƒ|j|_i|_|jsêtd|j|fƒ‚dS)NÚrbz Ú create_statsz.Cannot create or construct a %r object from %r)rÚ isinstanceÚstrÚopenÚmarshalÚloadÚosÚstatÚtimeÚctimeÚst_mtimerÚhasattrr$Ú TypeErrorÚ __class__)r r ÚfZ file_statsrrrr^s(      zStats.load_statscCs¬x¥|jjƒD]”\}\}}}}}|j|7_|j|7_|j|7_d|krt|jj|ƒtt|ƒƒ|j krtt|ƒƒ|_ qWdS)NÚjprofilerÚprofiler)r3rr4) rÚitemsrrrrr rÚfunc_std_stringr)r ÚfuncÚccÚncÚttÚctÚcallersrrrr ts+ zStats.get_top_level_statscGsF|s |Sx5t|ƒD]'}t|ƒt|ƒkrAt|ƒ}|j|j7_|j|j7_|j|j7_|j|j7_x!|jD]}|jj|ƒq“W|j |j krË|j |_ d|_ xg|j j ƒD]V\}}||j kr|j |}nddddif}t ||ƒ|j ||jƒD]0\}} ||krŠi||<| ||| ggð?gà?rz6 List reduced from %r to %r due to restriction <%r> ) r%r&ÚreÚcompileÚerrorÚsearchr6rcrÚfloatra)r ZselÚlistÚmsgZnew_listZrexr7ÚcountrrrÚeval_print_amounts,  ++zStats.eval_print_amountcCs|j}|jr9|jdd…}d|jd}nt|jjƒƒ}d}x)|D]!}|j|||ƒ\}}q[Wt|ƒ}|sœd|fSt|d|j ƒ|t|jƒkrd}x8|D]0}tt |ƒƒ|krÑtt |ƒƒ}qÑW|d|fS)Nz Ordered by: Ú z! Random listing order was used rrrY) rrrbrurÚkeysrxrr"rr6)r Zsel_listÚwidthZ stat_listrvZ selectionrwr7rrrÚget_print_list2s$      zStats.get_print_listcGs[x$|jD]}t|d|jƒq W|jr@td|jƒd}x-|jD]"}t|t|ƒd|jƒqPWt||jdddd|jƒ|j|jkrÊtd|jddd|jƒtd|jd|jƒtd|jƒ|j|ƒ\}}|rW|j ƒx|D]}|j |ƒq Wtd|jƒtd|jƒ|S) Nrú ézfunction callsÚendz(%d primitive calls)zin %.3f secondsz ) rr"rrÚfunc_get_function_namerrrr|Ú print_titleÚ print_line)r ÚamountrDÚindentr7r{rurrrÚ print_statsJs(  "   zStats.print_statscGs©|j|ƒ\}}|r¥|jƒ|j|dƒxM|D]E}||jkrn|j|||j|ƒq<|j||iƒq<Wtd|jƒtd|jƒ|S)Nz called...r)r|roÚprint_call_headingrÚprint_call_liner"r)r rƒr{rur7rrrÚ print_calleesas  zStats.print_calleesc Gs’|j|ƒ\}}|rŽ|j|dƒx@|D]8}|j|\}}}}} |j||| dƒq2Wtd|jƒtd|jƒ|S)Nzwas called by...z<-r)r|r†rr‡r"r) r rƒr{rur7r8r9r:r;r<rrrÚ print_callersps zStats.print_callersc Cs¢tdj|ƒ|d|jƒd}xT|jjƒD]C\}}}}}|r6tt|jƒƒƒ} t| tƒ}Pq6W|ržtd|dd|jƒdS)Nz Function rFr}z ncalls tottime cumtime) r"ÚljustrrÚvaluesÚnextÚiterr%rg) r Ú name_sizeZ column_titleZ subheaderr8r9r:r;r<Úvaluerrrr†{s %zStats.print_call_headingz->cCsktt|ƒj|ƒ|ddd|jƒ|sFtd|jƒdSt|jƒƒ}d}x|D]þ}t|ƒ}||} t| tƒr| \} } } } | | krÁd| | f}n d| f}d|jdd t |ƒƒt | ƒt | ƒ|f}|d }n.d || t |j |d ƒf}|d }t|||d|jƒd}qeWdS) Nrr}rrz%d/%dz%dz %s %s %s %srWrYrz %s(%r) %srH) r"r6rŠrÚsortedrzr%rgÚrjustrÚf8r)r rŽÚsourceZ call_dictZarrowZclistr„r7rQr�r9r8r:r;ZsubstatsZ left_widthrrrr‡‡s*,      $ zStats.print_call_linecCs0tdddd|jƒtdd|jƒdS)Nz- ncalls tottime percall cumtime percallrr}rzfilename:lineno(function))r"r)r rrrr� szStats.print_titlecCs[|j|\}}}}}t|ƒ}||krH|dt|ƒ}t|jdƒddd|jƒtt|ƒddd|jƒ|dkr±tdddd|jƒn#tt||ƒddd|jƒtt|ƒddd|jƒ|dkrtd ddd|jƒn#tt||ƒddd|jƒtt|ƒd|jƒdS) Nú/é rr}rrr~z z )rr&r"r‘rr’r6)r r7r8r9r:r;r<Úcrrrr‚¤s  " # #zStats.print_liner©rr©r—)r˜rGr©rr©r™)ršrGr©rHr©r›)rœrIr©rHr©r�)ržrI©rKr©rŸ)r rL©rKr©r¡)r¢rL©rNr©r£)r¤rO©rKr©r¥)r¦rL©rRr©r§)r¨rS©rRr©rKr©rNr©r©rªr«)r¬rTr©rr©r­)r®rU©rWr©r¯)r°rXr©rYr©r±)r²rZr©rYr©r³)r´rZ)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr rr r rEr[r_rhrjrnrorxr|r…rˆr‰r†r‡r�r‚rrrrr sF                c@s.eZdZdZdd„Zdd„ZdS)rea•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)Úcomp_select_list)r r¹rrrr¾szTupleComp.__init__cCsSxL|jD]A\}}||}||}||kr;| S||kr |Sq WdS)Nr)r¹)r ÚleftÚrightÚindexÚ directionÚlÚrrrrrfÁs    zTupleComp.compareN)rµr¶r·r¸rrfrrrrre¶s  recCs(|\}}}tjj|ƒ||fS)N)r*ÚpathÚbasename)Ú func_namerDrMrQrrrrkÏsrkcCs|dS)NrYr)r7rrrr€Ósr€cCsc|dd…d krW|d}|jdƒrP|jdƒrPd|dd …S|Snd|SdS) NrYú~rú<ú>z{%s}rz %s:%d(%s))rÃrr)Ú startswithÚendswith)rÂrQrrrr6Ös  r6c CsV|\}}}}}|\}}} } } |||||| || t| |ƒfS)z3Add together all the stats for two profile entries.)Ú add_callers) Útargetr“r8r9r:r;r<Zt_ccZt_ncZt_ttZt_ctZ t_callersrrrr?çsr?cCs±i}x$|jƒD]\}}|||÷s zadd_callers..)r5r%rgÚzip)rÉr“Z new_callersr7rmrrrrÈîs  !rÈcCs+d}x|jƒD]}||7}qW|S)z@Sum the caller statistics to get total number of calls received.r)r‹)r<r9rFrrrÚ count_callssrÎcCsd|S)Nz%8.3fr)Úxrrrr’ sr’Ú__main__c@sKeZdZddd„Zdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„ZdS)6ÚProfileBrowserNcCsKtjj|ƒd|_d|_tj|_|dk rG|j|ƒdS)Nz% ) ÚcmdÚCmdrÚpromptrrrrÚdo_read)r Úprofilerrrrs     zProfileBrowser.__init__cCsû|jƒ}g}x­|D]¥}y|jt|ƒƒwWntk rMYnXyNt|ƒ}|dksu|dkr‹tdd|jƒw|j|ƒwWntk r°YnX|j|ƒqW|jrät|j|ƒ|Œntdd|jƒdS)Nrrz#Fraction argument must be in [0, 1]rzNo statistics object is loaded.) ÚsplitrcraÚ ValueErrorrtr"rrÚgetattr)r ÚfnrMr Z processedZtermZfracrrrÚgeneric"s,       zProfileBrowser.genericcCsvtdd|jƒtdd|jƒtdd|jƒtdd|jƒtdd|jƒtdd|jƒdS)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)r rrrÚ generic_help:s zProfileBrowser.generic_helpcCs||jrey|jj|ƒWqxtk ra}z"td||fd|jƒWYdd}~XqxXntdd|jƒdS)Nz$Failed to load statistics for %s: %srzNo statistics object is loaded.r)rr ÚIOErrorr"r)r rMÚerrrÚdo_addBs 3zProfileBrowser.do_addcCstdd|jƒdS)Nz>Add profile info from given file to current statistics object.r)r"r)r rrrÚhelp_addKszProfileBrowser.help_addcCs|jd|ƒS)Nrˆ)rÛ)r rMrrrÚ do_calleesNszProfileBrowser.do_calleescCs!tdd|jƒ|jƒdS)Nz6Print callees statistics from the current stat object.r)r"rrÜ)r rrrÚ help_calleesPszProfileBrowser.help_calleescCs|jd|ƒS)Nr‰)rÛ)r rMrrrÚ do_callersTszProfileBrowser.do_callerscCs!tdd|jƒ|jƒdS)Nz6Print callers statistics from the current stat object.r)r"rrÜ)r rrrÚ help_callersVszProfileBrowser.help_callerscCstdd|jƒdS)Nrrr)r"r)r rMrrrÚdo_EOFZszProfileBrowser.do_EOFcCstdd|jƒdS)NzLeave the profile brower.r)r"r)r rrrÚhelp_EOF]szProfileBrowser.help_EOFcCsdS)Nrr)r rMrrrÚdo_quit`szProfileBrowser.do_quitcCstdd|jƒdS)NzLeave the profile brower.r)r"r)r rrrÚ help_quitbszProfileBrowser.help_quitcCs|r·yt|ƒ|_Wn‹tk r^}z#t|jdd|jƒdSWYdd}~XnItk r¦}z)t|jjd|d|jƒdSWYdd}~XnX|d|_ nKt |j ƒdkrï|j dd…}|j |ƒntdd|jƒdS) Nrrú:z% rYz1No statistics object is current -- cannot reload.réþÿÿÿ) rrÚOSErrorr"r rr!r1rµrÔrrÕ)r rMÚerrrrrrÕes zProfileBrowser.do_readcCs*tdd|jƒtdd|jƒdS)Nz+Read in profile data from a specified file.rz*Without argument, reload the current file.)r"r)r rrrÚ help_readvszProfileBrowser.help_readcCs0|jr|jjƒntdd|jƒdS)NzNo statistics object is loaded.rr)rrjr"r)r rMrrrÚ do_reversezs zProfileBrowser.do_reversecCstdd|jƒdS)Nz/Reverse the sort order of the profiling report.r)r"r)r rrrÚ help_reverse€szProfileBrowser.help_reversecsË|js tdd|jƒdS|jjƒ‰|rst‡fdd†|jƒDƒƒrs|jj|jƒŒnTtdd|jƒx>tjj ƒD]-\}}td||dfd|jƒq–WdS) NzNo statistics object is loaded.rc3s|]}|ˆkVqdS)Nr)rÊrÏ)Úabbrevsrrú ˆsz)ProfileBrowser.do_sort..z/Valid sort keys (unique prefixes are accepted):z%s -- %srr) rr"rr_Úallr×rhrr[r5)r rMr`r�r)rðrÚdo_sortƒs +%zProfileBrowser.do_sortcCs*tdd|jƒtdd|jƒdS)Nz.Sort profile data according to specified keys.rz3(Typing `sort' without arguments lists valid keys.))r"r)r rrrÚ help_sort�szProfileBrowser.help_sortcs‡fdd†tjDƒS)Ncs%g|]}|jˆƒr|‘qSr)rÆ)rÊÚa)ÚtextrrrÌ“s z0ProfileBrowser.complete_sort..)rr[)r rör r)rörÚ complete_sort’szProfileBrowser.complete_sortcCs|jd|ƒS)Nr…)rÛ)r rMrrrÚdo_stats•szProfileBrowser.do_statscCs!tdd|jƒ|jƒdS)Nz.Print statistics from the current stat object.r)r"rrÜ)r rrrÚ help_stats—szProfileBrowser.help_statscCs0|jr|jjƒntdd|jƒdS)NzNo statistics object is loaded.r)rrnr"r)r rMrrrÚdo_strip›s zProfileBrowser.do_stripcCstdd|jƒdS)NzsH      ÿ—         ’