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
3 \Ägã@sfdZddlZddlZddlZddlZddlZddlmZdgZGdd„dƒZ Gdd„dƒZ dd „Z d d „Z d d „Z dd„Zdd„Zdd„Zdd„Zedk�rbddlZy ddlZWnek rÄYnXGdd„dejƒZeejƒdkròejdZndZyTeeƒZx"ejdd…D]Zejeƒ�qWedejd�ej ƒedejd�Wne!k �r`YnXdS)z3Class for printing reports on profiled python code.éN)Ú cmp_to_keyÚStatsc@sÚeZdZdZddœdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dBdFdJdNdQdTdWdZd]dbdfdidmdqd!œZ d"d#„Z d$d%„Z d&d'„Z d(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zdrd9d:„Zd;d<„Zd=d>„ZdS)sra–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) N)ÚstreamcGsF|ptj|_t|ƒsd}n|d}|dd…}|j|ƒ|j|ŽdS)Nré)ÚsysÚstdoutrÚlenÚinitÚadd)ÚselfrÚargsÚarg©rú/usr/lib64/python3.6/pstats.pyÚ__init__As   zStats.__init__c Cs’d|_g|_d|_d|_d|_d|_d|_tƒ|_i|_ i|_ |j |ƒy |j ƒWn8t k rŒtd|jrx|jdnd|jd�‚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ƒrxt|dƒ�}tj|ƒ|_WdQRXy"tj|ƒ}tj |j ƒd|}Wn YnX|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ÚtimeZctimeÚst_mtimerÚhasattrr$Ú TypeErrorÚ __class__)r r ÚfZ file_statsrrrr^s(     zStats.load_statscCs„x~|jjƒD]p\}\}}}}}|j|7_|j|7_|j|7_d|kr\|jj|ƒtt|ƒƒ|j kr tt|ƒƒ|_ q WdS)NÚjprofilerÚprofiler)r2rr3) rÚitemsrrrrr rÚfunc_std_stringr)r ÚfuncÚccÚncÚttÚctÚcallersrrrr ts zStats.get_top_level_statscGsø|s|Sxêt|ƒD]Þ}t|ƒt|ƒkr.t|ƒ}|j|j7_|j|j7_|j|j7_|j|j7_x|jD]}|jj|ƒqvW|j |j krž|j |_ d|_ xJ|j j ƒD]<\}}||j krÎ|j |}nddddif}t ||ƒ|j |<q°WqW|S)Nr)ÚreversedÚtyperrrrrrr rrrr4Úadd_func_stats)r Úarg_listÚitemr6r+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)r Úfilenamer1rrrÚ dump_stats˜s zStats.dump_statsrú call countéúcumulative timeéú file nameéú line numberéú function nameúname/file/linerúprimitive call countéú standard nameéú internal time)ÚcallsZncallsZcumtimeÚ cumulativerrCÚlineÚmoduleÚnameZnflZpcallsÚstdnamer,ZtottimecCs€|jszi|_}i}xP|jjƒD]B\}}|}x4|r`|s8P||krJd||<P|||<|dd…}q.Wq Wx|D] }||=qlW|jS)z)Expand all abbreviations that are unique.rNrr)rÚsort_arg_dict_defaultr4)r ÚdictZbad_listÚwordÚtupZfragmentrrrÚget_sort_arg_defs°s    zStats.get_sort_arg_defscGs"|sd|_|St|ƒdkrFt|dtƒrFd dddddddi|dg}|jƒ}f}d|_d}x:|D]2}|||d}|j|||d7_d }qbWg}xB|jjƒD]4\}\}} } } } |j|| | | f|t |ƒ|fƒq¨W|j t t |ƒj ƒd �g|_} x|D]}| j|d ƒ�qW|S) NrrrYrTr,rRrUrz, )Úkeyrr)rrr%Úintr^Ú sort_typerr4Úappendr5ÚsortrÚ TupleCompÚcompare)r ZfieldZ sort_arg_defsZ sort_tupleZ connectorr\Z stats_listr6r7r8r9r:r;rÚtuplerrrÚ sort_statsÃs2   zStats.sort_statscCs|jr|jjƒ|S)N)rÚreverse)r rrrÚ reverse_orderãs zStats.reverse_ordercCsú|j}i|_}d}x |jƒD]”\}\}}}}} t|ƒ} tt| ƒƒ|krTtt| ƒƒ}i} x | jƒD]\} } | | t| ƒ<qbW| |kr t|| ||||| fƒ|| <q||||| f|| <qW|j}tƒ|_}x|D]}|jt|ƒƒqÎW||_ d|_ d|_ |S)Nr) rr4Úfunc_strip_pathrr5r>rrr rrr)r ZoldstatsZnewstatsrr6r7r8r9r:r;ZnewfuncZ newcallersÚfunc2ÚcallerZold_topZnew_toprrrÚ strip_dirsès.    zStats.strip_dirsc Cs||jr dSi|_}xb|jjƒD]T\}\}}}}}||krBi||<x0|jƒD]$\}} ||krdi||<| |||<qLWq WdS)N)rrr4) r rr6r7r8r9r:r;rkrlrrrÚ calc_calleess zStats.calc_calleesc Cs|}t|tƒrpytj|ƒ}Wn&tjk rB|d|7}||fSXg}x |D]}|jt|ƒƒrN|j|ƒqNWnzt|ƒ}t|t ƒr¸d|ko”dknr¸t ||dƒ}|d|…}n2t|t ƒrêd|koÔ|knrê|}|d|…}t|ƒt|ƒk�r|dt|ƒt|ƒ|f7}||fS)Nz# ggð?gà?rz6 List reduced from %r to %r due to restriction <%r> ) r%r&ÚreÚcompileÚerrorÚsearchr5rbrÚfloatr`)r ZselÚlistÚmsgZnew_listZrexr6ÚcountrrrÚeval_print_amounts,    "" zStats.eval_print_amountcCsÆ|j}|jr*|jdd…}d|jd}nt|jjƒƒ}d}x|D]}|j|||ƒ\}}qBWt|ƒ}|spd|fSt||j d�|t|jƒkrºd}x(|D] }tt |ƒƒ|kr–tt |ƒƒ}q–W|d|fS)Nz Ordered by: Ú z! Random listing order was used r)rrR) rrrartrÚkeysrwrr"rr5)r Zsel_listÚwidthZ stat_listruZ selectionrvr6rrrÚget_print_list2s$  zStats.get_print_listcGsþx|jD]}t||jd�qW|jr0t|jd�d}x"|jD]}t|t|ƒ|jd�qcCs tt|ƒj|ƒ|d|jd�|s2t|jd�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||||jd�d}qHWdS) Nr|)r~r)rrz%d/%dz%dz %s %s %s %srPrRrz %s(%r) %srF) r"r5r‰rÚsortedryr%rfÚrjustrÚf8r)r r�ÚsourceZ call_dictZarrowZclistrƒr6rXrŽr8r7r9r:ZsubstatsZ left_widthrrrr†‡s*       zStats.print_call_linecCs"tdd|jd�td|jd�dS)Nz- ncalls tottime percall cumtime percallr|)r~rzfilename:lineno(function))r)r"r)r rrrr€ szStats.print_titlecCsì|j|\}}}}}t|ƒ}||kr4|dt|ƒ}t|jdƒd|jd�tt|ƒd|jd�|dkrxtdd|jd�ntt||ƒd|jd�tt|ƒd|jd�|dkr¾td d|jd�ntt||ƒd|jd�tt|ƒ|jd�dS) Nú/é r|)r~rrr})rz z )rr&r"r‘rr’r5)r r6r7r8r9r:r;Úcrrrr�¤szStats.print_liner©rr©r—)r˜rEr©rr©r™)ršrEr©rFr©r›)rœrGr©rFr©r�)ržrG©rHr©rŸ)r rI©rHr©r¡)r¢rI©rJr©r£)r¤rK©rHr©r¥)r¦rI©rLr©r§)r¨rM©rLr©rHr©rJr©r©rªr«)r¬rNr©rr©r­)r®rO©rPr©r¯)r°rQr©rRr©r±)r²rSr©rRr©r³)r´rS)r�)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr rr r rDrZr^rgrirmrnrwr{r„r‡rˆr…r†r€r�rrrrr sF     c@s eZdZdZdd„Zdd„ZdS)rda•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__cCsBx<|jD]2\}}||}||}||kr.| S||kr|SqWdS)Nr)r¹)r ÚleftÚrightÚindexÚ directionÚlÚrrrrreÁszTupleComp.compareN)rµr¶r·r¸rrerrrrrd¶srdcCs|\}}}tjj|ƒ||fS)N)r*ÚpathÚbasename)Ú func_namerCrVrXrrrrjÏs rjcCs|dS)NrRr)r6rrrrÓsrcCsN|dd…d krB|d}|jdƒr<|jdƒrz{%s}rz %s:%d(%s))rÃrr)Ú startswithÚendswith)rÂrXrrrr5Ös r5c Cs@|\}}}}}|\}}} } } |||||| || t| |ƒfS)z3Add together all the stats for two profile entries.)Ú add_callers) Útargetr“r7r8r9r:r;Zt_ccZt_ncZt_ttZt_ctZ t_callersrrrr>çsr>cCsŠi}x|jƒD]\}}|||<qWxb|jƒD]V\}}||krzt|tƒrhtdd„t|||ƒDƒƒ||<q‚|||7<q,|||<q,W|S)z*Combine two caller lists in a single list.cSsg|]}|d|d‘qS)rrr)Ú.0Úirrrú ÷szadd_callers..)r4r%rfÚzip)rÉr“Z new_callersr6rlrrrrÈî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;r8rTrrrÚ count_callss rÎcCsd|S)Nz%8.3fr)Úxrrrr’ sr’Ú__main__c@sÞeZdZd6dd„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)7ÚProfileBrowserNcCs6tjj|ƒd|_d|_tj|_|dk r2|j|ƒdS)Nz% ) ÚcmdÚCmdrÚpromptrrrrÚdo_read)r Úprofilerrrrs  zProfileBrowser.__init__cCsÆ|jƒ}g}xŽ|D]†}y|jt|ƒƒwWntk r>YnXy8t|ƒ}|dksZ|dkrjtd|jd�w|j|ƒwWntk rŒYnX|j|ƒqW|jr´t|j|ƒ|Žntd|jd�dS)Nrrz#Fraction argument must be in [0, 1])rzNo statistics object is loaded.) Úsplitrbr`Ú ValueErrorrsr"rrÚgetattr)r ÚfnrVr Z processedZtermZfracrrrÚgeneric"s,  zProfileBrowser.genericcCsXtd|jd�td|jd�td|jd�td|jd�td|jd�td|jd�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_helpcCsd|jrRy|jj|ƒWq`tk rN}ztd||f|jd�WYdd}~Xq`Xntd|jd�dS)Nz$Failed to load statistics for %s: %s)rzNo statistics object is loaded.r)rr ÚIOErrorr"r)r rVÚerrrÚdo_addBs*zProfileBrowser.do_addcCstd|jd�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 rVrrrÚ do_calleesNszProfileBrowser.do_calleescCstd|jd�|jƒdS)Nz6Print callees statistics from the current stat object.)r)r"rrÜ)r rrrÚ help_calleesPszProfileBrowser.help_calleescCs |jd|ƒS)Nrˆ)rÛ)r rVrrrÚ do_callersTszProfileBrowser.do_callerscCstd|jd�|jƒdS)Nz6Print callers statistics from the current stat object.)r)r"rrÜ)r rrrÚ help_callersVszProfileBrowser.help_callerscCstd|jd�dS)Nr)rr)r"r)r rVrrrÚdo_EOFZszProfileBrowser.do_EOFcCstd|jd�dS)NzLeave the profile brower.)r)r"r)r rrrÚhelp_EOF]szProfileBrowser.help_EOFcCsdS)Nrr)r rVrrrÚdo_quit`szProfileBrowser.do_quitcCstd|jd�dS)NzLeave the profile brower.)r)r"r)r rrrÚ help_quitbszProfileBrowser.help_quitcCsÄ|rŠyt|ƒ|_Wnjtk rF}zt|jd|jd�dSd}~Xn8tk r|}zt|jjd||jd�dSd}~XnX|d|_ n6t |j ƒdkr²|j dd…}|j |ƒntd|jd�dS) Nr)rú:z% rRz1No statistics object is current -- cannot reload.réþÿÿÿ) rrÚOSErrorr"r rr!r0rµrÔrrÕ)r rVÚerrrrrrÕes  zProfileBrowser.do_readcCs td|jd�td|jd�dS)Nz+Read in profile data from a specified file.)rz*Without argument, reload the current file.)r"r)r rrrÚ help_readvszProfileBrowser.help_readcCs$|jr|jjƒntd|jd�dS)NzNo statistics object is loaded.)rr)rrir"r)r rVrrrÚ do_reversezs zProfileBrowser.do_reversecCstd|jd�dS)Nz/Reverse the sort order of the profiling report.)r)r"r)r rrrÚ help_reverse€szProfileBrowser.help_reversecs–|jstd|jd�dS|jjƒ‰|rRt‡fdd„|jƒDƒƒrR|jj|jƒŽn@td|jd�x0tjj ƒD]"\}}td||df|jd�qlWdS) 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×rgrrZr4)r rVr_rŽr)rðrÚdo_sortƒs zProfileBrowser.do_sortcCs td|jd�td|jd�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)Ncsg|]}|jˆƒr|‘qSr)rÆ)rÊÚa)ÚtextrrrÌ“sz0ProfileBrowser.complete_sort..)rrZ)r rör r)rörÚ complete_sort’szProfileBrowser.complete_sortcCs |jd|ƒS)Nr„)rÛ)r rVrrrÚdo_stats•szProfileBrowser.do_statscCstd|jd�|jƒdS)Nz.Print statistics from the current stat object.)r)r"rrÜ)r rrrÚ help_stats—szProfileBrowser.help_statscCs$|jr|jjƒntd|jd�dS)NzNo statistics object is loaded.)r)rrmr"r)r rVrrrÚdo_strip›s zProfileBrowser.do_stripcCstd|jd�dS)NzrÈrÎr’rµrÒÚreadlineÚ ImportErrorrÓrÑrÚargvZ initprofileZbrowserrÖrßr"rZcmdloopÚKeyboardInterruptrrrrÚsN