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 \Vã@s„dZddlZddlZddlZddlZddlmZdddgZGdd„dƒZdd d„Z dd d„Z Gd d„dƒZ d d„Z e dkr€e ƒdS)z Class for profiling Python code.éN)Ú OptionParserÚrunÚrunctxÚProfilec@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú_UtilszŠSupport class for utility functions which are shared by profile.py and cProfile.py modules. Not supposed to be used directly. cCs ||_dS)N)Úprofiler)Úselfr©r ú/usr/lib64/python3.6/profile.pyÚ__init__1sz_Utils.__init__cCsF|jƒ}z(y|j|ƒWntk r,YnXWd|j|||ƒXdS)N)rrÚ SystemExitÚ_show)rÚ statementÚfilenameÚsortÚprofr r r r4s  z _Utils.runcCsJ|jƒ}z,y|j|||ƒWntk r0YnXWd|j|||ƒXdS)N)rrr r )rrÚglobalsÚlocalsrrrr r r r=s  z _Utils.runctxcCs"|dk r|j|ƒn |j|ƒdS)N)Ú dump_statsÚ print_stats)rrrrr r r r Fs z _Utils._showN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrr r r r r r+s   récCsttƒj|||ƒS)aRun statement under profiler optionally saving results in filename This function takes a single argument that can be passed to the "exec" statement, and an optional file name. In all cases this routine attempts to "exec" its first argument and gather profiling statistics from the execution. If no file name is present, then this function automatically prints a simple profiling report, sorted by the standard name string (file/line/function-name) that is presented in each line. )rrr)rrrr r r rRs cCsttƒj|||||ƒS)z·Run statement under profiler, supplying your own globals and locals, optionally saving results in filename. statement and filename have the same semantics as profile.run )rrr)rrrrrr r r r_sc@sðeZdZdZdZd4dd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z e e e e e e dœZdd„ZGdd„dƒZGdd„dƒZdd„Zdd „Zd6d"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd7d0d1„Zd2d3„ZdS)8raProfiler class. self.cur is always a tuple. Each such tuple corresponds to a stack frame that is currently active (self.cur[-2]). The following are the definitions of its members. We use this external "parallel stack" to avoid contaminating the program that we are profiling. (old profiler used to write into the frames local dictionary!!) Derived classes can change the definition of some entries, as long as they leave [-2:] intact (frame and previous tuple). In case an internal error is detected, the -3 element is used as the function name. [ 0] = Time that needs to be charged to the parent frame's function. It is used so that a function call will not have to access the timing data for the parent frame. [ 1] = Total time spent in this frame's function, excluding time in subfunctions (this latter is tallied in cur[2]). [ 2] = Total time spent in subfunctions, excluding time executing the frame's function (this latter is tallied in cur[1]). [-3] = Name of the function that corresponds to this frame. [-2] = Actual frame that we correspond to (used to sync exception handling). [-1] = Our parent 6-tuple (corresponds to frame.f_back). Timing data for each function is stored as a 5-tuple in the dictionary self.timings[]. The index is always the name stored in self.cur[-3]. The following are the definitions of the members: [0] = The number of times this function was called, not counting direct or indirect recursion, [1] = Number of times this function appears on the stack, minus one [2] = Total time spent internal to this function [3] = Cumulative time that this function was present on the stack. In non-recursive functions, this is the total execution time from start to finish of each invocation of a function, including time spent in all subfunctions. [4] = A dictionary indicating for each function name, the number of times it was called by us. rNc CsÌi|_d|_d|_d|_|dkr&|j}||_|sHtj|_|_|j |_ nl||_|jƒ}y t |ƒ}Wn"t k r„||_|j |_ Yn0X|dkr˜|j |_ n|j|_ |tfdd„}||_|jƒ|_|jdƒdS)NÚécSs ||ƒƒS)Nr )ÚtimerÚsumr r r Úget_time_timer°sz(Profile.__init__..get_time_timerr)ÚtimingsÚcurÚcmdÚ c_func_nameÚbiasÚtimeZ process_timerÚget_timeÚtrace_dispatch_iÚ dispatcherÚlenÚ TypeErrorÚtrace_dispatchÚtrace_dispatch_lrÚtÚ simulate_call)rrr$r-Zlengthrr r r r ‘s0    zProfile.__init__cCs„|j}|ƒ}|d|d|j|j}|dkr8|j|_|j||||ƒrd|ƒ}|d|d|_n|ƒ}|d|d||_dS)NrrÚc_call)rr-r$rr#Údispatch)rÚframeÚeventÚargrr-Úrr r r r+¸szProfile.trace_dispatchcCsT|j}|ƒ|j|j}|dkr(|j|_|j||||ƒrD|ƒ|_n |ƒ||_dS)Nr/)rr-r$rr#r0)rr1r2r3rr-r r r r'Ês zProfile.trace_dispatch_icCs`|j}|ƒd|j|j}|dkr,|j|_|j||||ƒrL|ƒd|_n|ƒd||_dS)NgN@r/)rr-r$rr#r0)rr1r2r3rr-r r r Útrace_dispatch_macÙszProfile.trace_dispatch_maccCsT|j}|ƒ|j|j}|dkr(|j|_|j||||ƒrD|ƒ|_n |ƒ||_dS)Nr/)r&r-r$rr#r0)rr1r2r3r&r-r r r r,çs zProfile.trace_dispatch_lc CsD|j\}}}}}}||k r*|r*|j||ƒS|||||||f|_dS)Nr)r!Útrace_dispatch_return) rr1r-ÚrptÚritÚretÚrfnÚrframeÚrcurr r r Útrace_dispatch_exceptionús   z Profile.trace_dispatch_exceptioncCs¸|jr@|j|jdk r@|j\}}}}}}t|tjƒs@|j|dƒ|j} | j| j| j f} |dd| ||jf|_|j } | | kr¢| | \} } }}}| | d|||f| | <nddddif| | <dS)Nrrréþÿÿÿ) r!Úf_backÚ isinstancerÚ fake_framer6Úf_codeÚ co_filenameÚco_firstlinenoÚco_namer )rr1r-r7r8r9r:r;r<ZfcodeÚfnr ÚccÚnsÚttÚctÚcallersr r r Útrace_dispatch_calls  zProfile.trace_dispatch_callc Csndd|jf}|dd|||jf|_|j}||krX||\}}}}} ||d||| f||<nddddif||<dS)Nrrr)r#r!r ) rr1r-rFr rGrHrIrJrKr r r Útrace_dispatch_c_calls zProfile.trace_dispatch_c_callcCsØ||jdk r |j|jddƒ|j\}}}}}}||}||}|\} } } } } }| | || || | |f|_|j}||\}}}}}|s˜||}|d}| |kr²|| d|| <nd|| <||d||||f||<dS)Nrrrr>r>)r!r6r )rr1r-r7r8r9r:r<Z frame_totalZpptZpitZpetZpfnÚpframeZpcurr rGrHrIrJrKr r r r6#s"zProfile.trace_dispatch_return)ÚcallZ exceptionÚreturnr/Z c_exceptionZc_returncCs"|jdrdS||_|j|ƒdS)Nréÿÿÿÿ)r!r"r.)rr"r r r Úset_cmdYs zProfile.set_cmdc@seZdZdd„Zdd„ZdS)zProfile.fake_codecCs||_||_||_d|_dS)Nr)rCÚco_linerErD)rrÚlineÚnamer r r r _szProfile.fake_code.__init__cCst|j|j|jfƒS)N)ÚreprrCrSrE)rr r r Ú__repr__eszProfile.fake_code.__repr__N)rrrr rWr r r r Ú fake_code^srXc@seZdZdd„ZdS)zProfile.fake_framecCs||_||_dS)N)rBr?)rÚcodeZpriorr r r r iszProfile.fake_frame.__init__N)rrrr r r r r rAhsrAcCsF|jdd|ƒ}|jr |jd}nd}|j||ƒ}|jd||dƒdS)NZprofilerrrOr>)rXr!rAr0)rrUrYrNr1r r r r.ms   zProfile.simulate_callcCsN|j}|ƒ|j}x*|jdr<|jd||jd|ƒd}qW|ƒ||_dS)NrrPrrrQr>)r&r-r!r0)rr&r-r r r Úsimulate_cmd_completeys   zProfile.simulate_cmd_completercCs$ddl}|j|ƒjƒj|ƒjƒdS)Nr)ÚpstatsZStatsZ strip_dirsZ sort_statsr)rrr[r r r r„szProfile.print_statsc Cs0t|dƒ�}|jƒtj|j|ƒWdQRXdS)NÚwb)ÚopenÚ create_statsÚmarshalÚdumpÚstats)rÚfileÚfr r r r‰s zProfile.dump_statscCs|jƒ|jƒdS)N)rZÚsnapshot_stats)rr r r r^ŽszProfile.create_statsc Csfi|_xZ|jjƒD]L\}\}}}}}|jƒ}d}x|jƒD] }||7}q:W|||||f|j|<qWdS)Nr)rar ÚitemsÚcopyÚvalues) rÚfuncrGrHrIrJrKZncZcallcntr r r rd’s zProfile.snapshot_statscCsddl}|j}|j|||ƒS)Nr)Ú__main__Ú__dict__r)rr"riÚdictr r r rŸsz Profile.runc Cs8|j|ƒtj|jƒzt|||ƒWdtjdƒX|S)N)rRÚsysÚ setprofiler(Úexec)rr"rrr r r r¤s    zProfile.runctxc Os6|jt|ƒƒtj|jƒz |||ŽStjdƒXdS)N)rRrVrlrmr()rrhÚargsÚkwr r r Úruncall®s   zProfile.runcallc Cs8|jtk rtdƒ‚|j}d|_z |j||ƒS||_XdS)Nz&Subclasses must override .calibrate().r)Ú __class__rr*r$Ú_calibrate_inner)rÚmÚverboseZ saved_biasr r r Ú calibrateßs  zProfile.calibratecCs$|j}dd„}|fdd„}||ƒ|ƒ}||ƒ|ƒ}||}|rLtd|ƒtƒ} |ƒ}| jdtƒtƒƒ|ƒ}||} |r†td| ƒd} d} x>| jjƒD]0\\} }}\}}}}}|dkrš| |7} | |7} qšW|rætd | ƒtd | ƒ| |d k�rtd| ƒ‚| |d| }|�r td|ƒ|S)NcSsxt|ƒD]}d}q WdS)Nr)Úrange)ÚnÚiÚxr r r Úf1ósz$Profile._calibrate_inner..f1cSsxt|ƒD] }|dƒq WdS)Néd)rw)rtr{ryr r r rc÷sz#Profile._calibrate_inner..fz elapsed time without profiling =zf(m)zelapsed time with profiling =grcr{z!'CPU seconds' profiler reported =ztotal # calls =rz internal error: total calls = %dg@z+mean stopwatch overhead per profile event =)rcr{) r&Úprintrrrrr reÚ ValueError)rrtrur&r{rcZt0Zt1Zelapsed_noprofileÚpZelapsed_profileZ total_callsZ reported_timerrTÚfuncnamerGrHrIrJrKZmeanr r r rsêsB   "     zProfile._calibrate_inner)NNrQ)rQ)r)rrrrr$r r+r'r5r,r=rLrMr6r0rRrXrAr.rZrrr^rdrrrqrvrsr r r r rhs>% ' '      1 c Csöd}t|d�}d|_|jdddddd�|jd d d d dd�tjd d…s\|jƒtjdƒ|jƒ\}}|tjdd…<t|ƒdkrê|d}tj j dt j j |ƒƒt |dƒ�}t|jƒ|dƒ}WdQRX|ddddœ}t||d|j|jƒn|jƒ|S)Nz?profile.py [-o output_file_path] [-s sort] scriptfile [arg] ...)ÚusageFz-oz --outfileÚoutfilezSave stats to )ÚdestÚhelpÚdefaultz-sz--sortrz?Sort order when printing to stdout, based on pstats.Stats classrrrÚrbrnri)Ú__file__rÚ __package__Ú __cached__rQ)rZallow_interspersed_argsZ add_optionrlÚargvZ print_usageÚexitÚ parse_argsr)ÚpathÚinsertÚosÚdirnamer]ÚcompileÚreadrr‚r)r�ÚparserZoptionsroZprognameÚfprYZglobsr r r Úmain*s2        r•rirQ)NrQrQ)NrQ)rrlr�r%r_ZoptparserÚ__all__rrrrr•rr r r r Ú s   ' E"