Ë ‚Ö¦i4Zãó�—dZddlZddlZddlZddlZddlZgd¢ZGd„d«Zd d„Z d d„Z Gd„d «Z d „Z e d k(re «yy) z Class for profiling Python code.éN)ÚrunÚrunctxÚProfilecó(—eZdZdZd„Zd„Zd„Zd„Zy)Ú_UtilszŠSupport class for utility functions which are shared by profile.py and cProfile.py modules. Not supposed to be used directly. có—||_y©N)Úprofiler)Úselfr s ú /usr/lib64/python3.12/profile.pyÚ__init__z_Utils.__init__1s €Ø ˆ� ócó¼—|j«} |j|«|j|||«y#t$rYŒwxYw#|j|||«wxYwr )r rÚ SystemExitÚ_show)r Ú statementÚfilenameÚsortÚprofs r rz _Utils.run4sW€Ø�}‰}‹ˆð -Ø �H‰H�YÔ ð �J‰J�t˜X tÕ ,øôò Ù ð ûð �J‰J�t˜X tÕ ,ús!’7· AÁAÁAÁAÁAcóÀ—|j«} |j|||«|j|||«y#t$rYŒwxYw#|j|||«wxYwr )r rrr)r rÚglobalsÚlocalsrrrs r rz _Utils.runctx=s[€Ø�}‰}‹ˆð -Ø �K‰K˜  7¨FÔ 3ð �J‰J�t˜X tÕ ,øôò Ù ð ûð �J‰J�t˜X tÕ ,ús!’9¹ AÁAÁAÁAÁAcóN—|�|j|«y|j|«yr )Ú dump_statsÚ print_stats)r rrrs r rz _Utils._showFs"€Ø Ð Ø �O‰O˜HÕ %à × Ñ ˜TÕ "rN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrr©rr rr+s„ñò !ò-ò-ó#rrcóB—tt«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)rrrs r rrRs€ô ”'‹?× Ñ ˜y¨(°DÓ 9Ð9rcóF—tt«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)rrrrrs r rr_s!€ô ”'‹?× !Ñ ! )¨W°f¸hÈÓ MÐMrcóÒ—eZdZdZdZdd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z d „Z e e e e e e d œZd„ZGd„d«ZGd„d«Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zd„Zd„Zd d„Zd„Zy)!raProfiler 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ó—i|_d|_d|_d|_|€ |j}||_|s.t j x|_|_|j|_ n\||_|j«} t|«}|dk(r|j|_ n|j|_ |tfd„}||_|j«|_|j#d«y#t$r||_|j|_ YŒJwxYw)NÚécó—||««Sr r )ÚtimerÚsums r Úget_time_timerz(Profile.__init__..get_time_timer°s€Ù™u›w›<Ð'rr )ÚtimingsÚcurÚcmdÚ c_func_nameÚbiasÚtimeÚ process_timer(Úget_timeÚtrace_dispatch_iÚ dispatcherÚlenÚtrace_dispatchÚtrace_dispatch_lr)Ú TypeErrorÚtÚ simulate_call)r r(r/r9Úlengthr*s r r zProfile.__init__‘sî€ØˆŒ ؈ŒØˆŒØˆÔà ˆ<Ø—9‘9ˆD؈Œ áÜ)-×):Ñ):Ð :ˆDŒJ˜œØ"×3Ñ3ˆD�OàˆDŒJØ— ‘ “ ˆAð /ܘQ›�ð ˜Q’;Ø&*×&9Ñ&9�D•Oà&*×&;Ñ&;�D”Oð */´Có(à .�” Ø—‘“ˆŒØ ×ј:Õ&øô#ò 8Ø %�” Ø"&×"7Ñ"7�–ð 8úsÁ: C%Ã%!D ÄD có2—|j}|«}|d|dz|jz |jz }|dk(r|j|_|j ||||«r|«}|d|dz|_y|«}|d|dz|z |_y)NréÚc_call©r(r9r/rr.Údispatch)r ÚframeÚeventÚargr(r9Úrs r r6zProfile.trace_dispatch¸s˜€Ø— ‘ ˆÙ ‹GˆØ ˆa‰D�1�Q‘4‰K˜$Ÿ&™&Ñ  4§9¡9Ñ ,ˆà �HÒ Ø"Ÿ|™|ˆDÔ à ˆ4�=‰=˜Ñ   e¨AÔ .Ù“ˆAØ�q‘T˜A˜a™D‘[ˆD�FᓈAØ�q‘T˜A˜a™D‘[ 1‘_ˆD�Frcóð—|j}|«|jz |jz }|dk(r|j|_|j ||||«r |«|_y|«|z |_y©Nr>r?©r rArBrCr(r9s r r3zProfile.trace_dispatch_iÊse€Ø— ‘ ˆÙ ‹G�d—f‘fÑ ˜tŸy™yÑ (ˆà �HÒ Ø"Ÿ|™|ˆDÔ à ˆ4�=‰=˜Ñ   e¨QÔ /Ù“WˆD�Fá“W˜q‘[ˆD�Frcó—|j}|«dz |jz |jz }|dk(r|j|_|j ||||«r|«dz |_y|«dz |z |_y)NgN@r>r?rGs r Útrace_dispatch_maczProfile.trace_dispatch_macÙsr€Ø— ‘ ˆÙ ‹G�D‰L˜4Ÿ6™6Ñ ! D§I¡IÑ -ˆà �HÒ Ø"Ÿ|™|ˆDÔ à ˆ4�=‰=˜Ñ   e¨QÔ /Ù“W˜T‘\ˆD�Fá“W˜T‘\ AÑ%ˆD�Frcóð—|j}|«|jz |jz }|dk(r|j|_|j ||||«r |«|_y|«|z |_yrF)r2r9r/rr.r@)r rArBrCr2r9s r r7zProfile.trace_dispatch_lçse€Ø—=‘=ˆÙ ‹J˜Ÿ™Ñ  $§)¡)Ñ +ˆà �HÒ Ø"Ÿ|™|ˆDÔ à ˆ4�=‰=˜Ñ   e¨QÔ /Ù“ZˆD�Fá“Z !‘^ˆD�Frcóz—|j\}}}}}}||ur|r|j||«S|||z||||f|_y©Nr=)r,Útrace_dispatch_return) r rAr9ÚrptÚritÚretÚrfnÚrframeÚrcurs r Útrace_dispatch_exceptionz Profile.trace_dispatch_exceptionúsP€Ø+/¯8©8Ñ(ˆˆS�#�s˜F DØ ˜%Ñ ¡TØ×-Ñ-¨f°aÓ8Ð 8ؘ˜A™˜s C¨°Ð5ˆŒØrcó®—|jrÐ|j|jdurµ|j\}}}}}}t|tj«sˆ|j|jus!Jd|||j||jf«‚|j |d«|j�1|j|jdusJd|jdf«‚|j } | j| j| jf} |dd| ||jf|_|j} | | vr| | \} } }}}| | dz|||f| | <yddddif| | <y)NéþÿÿÿzBad callréýÿÿÿr=) r,Úf_backÚ isinstancerÚ fake_framerMÚf_codeÚ co_filenameÚco_firstlinenoÚco_namer+)r rAr9rNrOrPrQrRrSÚfcodeÚfnr+ÚccÚnsÚttÚctÚcallerss r Útrace_dispatch_callzProfile.trace_dispatch_callsj€Ø �8Š8˜Ÿ ™ ¨D¯H©H°R©LÑ8Ø/3¯x©xÑ ,ˆC��c˜3 ¨Ü˜f¤g×&8Ñ&8Ô9Ø—}‘}¨¯ © Ñ4ðL°zÀ3Ø7=¸v¿}¹}Ø7<¸e¿l¹lð7LóLÐ4ð×*Ñ*¨6°1Ô5ØŸ™Ð(ØŸ ™ ¨¯©°© Ñ4ðFØ8BØ8<¿¹À¹ ð8FóFð5ð— ‘ ˆØ×Ñ ×!5Ñ!5°u·}±}Ð EˆØ�q˜!˜R ¨¯©Ð1ˆŒØ—,‘,ˆØ �‰=Ø&-¨b¡kÑ #ˆB��B˜˜Gؘb 1™f b¨"¨gÐ5ˆG�B‰Kðð˜Q  1 b˜.ˆG�B‰KØrcó¶—dd|jf}|dd|||jf|_|j}||vr||\}}}}} ||dz||| f||<yddddif||<y)Nr%rr=)r.r,r+) r rAr9r`r+rarbrcrdres r Útrace_dispatch_c_callzProfile.trace_dispatch_c_calls…€Ø�!�T×%Ñ%Ð &ˆØ�q˜!˜R ¨¯©Ð1ˆŒØ—,‘,ˆØ �‰=Ø&-¨b¡kÑ #ˆB��B˜˜Gؘb ™d B¨¨GÐ3ˆG�B‰Kðð˜Q  1 b˜.ˆG�B‰KØrcóÈ—||jdurP||jdjusJd|jdf«‚|j|jdd«|j\}}}}}}||z}||z}|\} } } } } }| | |z| |z| | |f|_|j}||\}}}}}|s ||z}|dz}| |vr || dz|| <nd|| <||dz ||z||f||<y)NrVz Bad returnrWrr=)r,rXrMr+)r rAr9rNrOrPrQrSÚ frame_totalÚpptÚpitÚpetÚpfnÚpframeÚpcurr+rarbrcrdres r rMzProfile.trace_dispatch_return#s)€Ø ˜Ÿ™ ™ Ñ $ؘDŸH™H R™L×/Ñ/Ñ/Ð M°,ÀÇÁÈÁ Ð1MÓ MÐ/Ø × &Ñ & t§x¡x°¡|°QÔ 7ð +/¯(©(Ñ'ˆˆS�#�s˜E 4Ø�A‰gˆØ˜C‘iˆ à+/Ñ(ˆˆS�#�s˜F Dؘ˜c™  3¨Ñ#4°c¸6À4ÐGˆŒà—,‘,ˆØ")¨#¡,шˆB��B˜Ùð �kÑ!ˆBØ�a‘ˆBà �'‰>Ø" 3™<¨!Ñ+ˆG�CŠLð ˆG�C‰Là˜2 ™6 2¨¡8¨R°Ð8ˆ�‰ àr)ÚcallÚ exceptionÚreturnr>Ú c_exceptionÚc_returncóT—|jdry||_|j|«y©Néÿÿÿÿ)r,r-r:)r r-s r Úset_cmdzProfile.set_cmdYs$€Ø �8‰8�BŠ<˜ØˆŒØ ×ј3Õrcó—eZdZd„Zd„Zy)úProfile.fake_codecó<—||_||_||_d|_y©Nr)r\Úco_liner^r])r rÚlineÚnames r r zProfile.fake_code.__init___s €Ø'ˆDÔ ØˆDŒL؈DŒLØ"#ˆDÕ rcóZ—t|j|j|jf«Sr )Úreprr\r~r^©r s r Ú__repr__zProfile.fake_code.__repr__es"€Ü˜×)Ñ)¨4¯<©<¸¿¹ÐFÓGÐ GrN)rrrr r„r rr Ú fake_coder{^s „ò $ó  Hrr…có—eZdZd„Zy)úProfile.fake_framecó —||_||_yr )r[rX)r ÚcodeÚpriors r r zProfile.fake_frame.__init__is€ØˆDŒK؈D�KrN)rrrr r rr rZr‡hs„ó rrZcó¸—|jdd|«}|jr|jd}nd}|j||«}|jd||d«y)NÚprofilerrVrq)r…r,rZr@)r r€r‰rorAs r r:zProfile.simulate_callmsT€Ø�~‰~˜i¨¨DÓ1ˆØ �8Š8Ø—X‘X˜b‘\‰FàˆFØ—‘  fÓ-ˆØˆ� ‰ �fјd E¨1Õ-rcóì—|j}|«|jz }|jdr6|jd||jd|«d}|jdrŒ6|«|z |_y)NrxrsrVr)r2r9r,r@)r r2r9s r Úsimulate_cmd_completezProfile.simulate_cmd_completeysh€Ø—=‘=ˆÙ ‹J˜Ÿ™Ñ ˆØ�h‰h�rŠlð $ˆD�M‰M˜(Ñ # D¨$¯(©(°2©,¸Ô :؈Að �h‰h�r‹lñ “˜a‘ˆ�rcó„—ddl}|j|«j«j|«j «yr})ÚpstatsÚStatsÚ strip_dirsÚ sort_statsr)r rr�s r rzProfile.print_stats„s,€ÛØ� ‰ �TÓ×%Ñ%Ó'×2Ñ2°4Ó8ß‘+•-rcó¦—t|d«5}|j«tj|j|«ddd«y#1swYyxYw)NÚwb)ÚopenÚ create_statsÚmarshalÚdumpÚstats)r ÚfileÚfs r rzProfile.dump_stats‰s8€Ü �$˜Ô  Ø × Ñ Ô Ü �L‰L˜Ÿ™ QÔ '÷× Ñ ús �1AÁAcóD—|j«|j«yr )rŽÚsnapshot_statsrƒs r r—zProfile.create_statsŽs€Ø ×"Ñ"Ô$Ø ×ÑÕrcóâ—i|_|jj«D]K\}\}}}}}|j«}d}|j «D]}||z }Œ |||||f|j|<ŒMyr})ršr+ÚitemsÚcopyÚvalues) r ÚfuncrarbrcrdreÚncÚcallcnts r ržzProfile.snapshot_stats’st€ØˆŒ Ø/3¯|©|×/AÑ/AÖ/CÑ +ˆDÑ+�2�r˜2˜r 7Ø—l‘l“nˆG؈BØ"Ÿ>™>Ö+�Ø�g‘ ‘ð,à! 2 r¨2¨wÐ6ˆD�J‰J�tÒ ñ 0DrcóH—ddl}|j}|j|||«Sr})Ú__main__Ú__dict__r)r r-r§Údicts r rz Profile.runŸs#€ÛØ× Ñ ˆØ�{‰{˜3  dÓ+Ð+rcóà—|j|«tj|j« t |||«tjd«|S#tjd«wxYwr )ryÚsysÚ setprofiler4Úexec)r r-rrs r rzProfile.runctx¤sP€Ø � ‰ �SÔÜ �‰�t—‘Ô'ð !Ü ��g˜vÔ &ä �N‰N˜4Ô Øˆ øô �N‰N˜4Õ ús ² AÁA-cóä—|jt|««tj|j« ||i|¤Žtjd«S#tjd«wxYwr )ryr‚r«r¬r4)r r£ÚargsÚkws r ÚruncallzProfile.runcall®sM€Ø � ‰ ”T˜$“ZÔ Ü �‰�t—‘Ô'ð !Ù˜Ð$ Ñ$ä �N‰N˜4Õ øŒC�N‰N˜4Õ ús »AÁA/có®—|jtur td«‚|j}d|_ |j ||«||_S#||_wxYw)Nz&Subclasses must override .calibrate().r)Ú __class__rr8r/Ú_calibrate_inner)r ÚmÚverboseÚ saved_biass r Ú calibratezProfile.calibrateßsN€Ø �>‰>¤Ñ (ÜÐDÓEÐ Eà—Y‘Yˆ ؈Œ ð #Ø×(Ñ(¨¨GÓ4à"ˆD�Iø˜ ˆD�Iús ²A Á Acó<—|j}d„}|fd„}||«|«}||«|«}||z }|r td|«t«} |«}| jdt «t ««|«}||z } |r td| «d} d} | j j«D]\\} }}\}}}}}|dvsŒ| |z } | |z } Œ |rtd| «td | «| |d zk7rtd | z«‚| |z d z | z }|r td |«|S)Ncó(—t|«D]}d}ŒyrL©Úrange)ÚnÚiÚxs r Úf1z$Profile._calibrate_inner..f1ós€Ü˜1–X�Ø‘ñrcó4—t|«D] }|d«Œ y)Nédr»)rµrÀr¾s r rœz#Profile._calibrate_inner..f÷s€Ü˜1–X�Ù�3•ñrz elapsed time without profiling =zf(m)zelapsed time with profiling =g)rœrÀz!'CPU seconds' profiler reported =ztotal # calls =r=z internal error: total calls = %dg@z+mean stopwatch overhead per profile event =) r2Úprintrrrrr+r Ú ValueError)r rµr¶r2rÀrœÚt0Út1Úelapsed_noprofileÚpÚelapsed_profileÚ total_callsÚ reported_timerrÚfuncnamerarbrcrdreÚmeans r r´zProfile._calibrate_innerêsN€Ø—=‘=ˆò ðó ñ ˆ!Œñ‹ZˆÙ ˆ!ŒÙ ‹ZˆØ ™GÐÙ Ü Ð4Ð6GÔ Hô ‹IˆÙ ‹ZˆØ �‰�œ›¤F£HÔ-Ù ‹ZˆØ˜r™'ˆÙ Ü Ð1°?Ô Cðˆ Øˆ à— ‘ —‘Ö!ñ BÑ &ˆX�t˜XÑ(A¨¨R°°R¸à˜;Ò&ؘrÑ!� Ø Ñ#‘ ð"ñ Ü Ð5°}Ô EÜ Ð# [Ô 1Ø ˜!˜a™%Ò ÜÐ?À+ÑMÓNÐ Nð Ð 1Ñ1°SÑ8¸;ÑFˆÙ Ü Ð?ÀÔ F؈ r)NN)rx)r)rrrrr/r r6r3rIr7rTrfrhrMr@ryr…rZr:rŽrrr—ržrrr±r¸r´r rr rrhs¬„ñ$ðL €Dó#'òN %ò$ !ò &ò $ò&òò, ò#ðN$Ø-Ø'Ø'Ø,Ø)ñ  €Hò  ÷ HñH÷ ñ ò .ò ó ò (ò ò7ò,ò ò!ób #ó<rrcó—ddl}ddlm}d}||¬«}d|_|j dddd d¬ «|j d d d dd¬«|j ddddd¬ «t j dds%|j«t jd«|j«\}}|t j dd|j�*|jj|j«|_ t|«dkD�r|jrddl}d}|j |ddœ}nµ|d} t jj#d|jj%| ««t'j(| «5} t+| j-«| d«}ddd«t.j0j3dd| ¬«} | | j4| j6dddœ} t9|d|j|j:«|S|j«|S#1swYŒxYw#t<$r5} dt _t j| j@«Yd} ~ |Sd} ~ wwxYw)Nr)Ú OptionParserzMprofile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...)ÚusageFz-oz --outfileÚoutfilezSave stats to )ÚdestÚhelpÚdefaultz-mÚmoduleÚ store_truezProfile a library module.)rÒÚactionrÓrÔz-sz--sortrz?Sort order when printing to stdout, based on pstats.Stats classrxr=r&z(run_module(modname, run_name='__main__'))Ú run_moduleÚmodnamer­r§)r€ÚloaderÚorigin)Ú__spec__Ú__file__rÚ __package__Ú __cached__)!ÚosÚoptparserÏÚallow_interspersed_argsÚ add_optionr«ÚargvÚ print_usageÚexitÚ parse_argsrÑÚpathÚabspathr5rÕÚrunpyrØÚinsertÚdirnameÚioÚ open_codeÚcompileÚreadÚ importlibÚ machineryÚ ModuleSpecrÛr€rrÚBrokenPipeErrorÚstdoutÚerrno) ràrÏrÐÚparserÚoptionsr¯rêr‰ÚglobsÚprognameÚfpÚspecÚexcs r Úmainrþ*s€Û Ý%à [€EÙ  Ô &€FØ%*€FÔ"Ø ×Ñ�d˜K¨iØ &°ðô6à ×Ñ�d °,Ø (°%ðô9à ×Ñ�d˜H¨6Ø NØðôô �8‰8�A�B‰<Ø×ÑÔÜ �‰�Œ à×'Ñ'Ó)�O€WˆdØ„C‡H�H‰Q€Kð‡�Ð"ØŸ'™'Ÿ/™/¨'¯/©/Ó:ˆŒä ˆ4ƒy�1ƒ}Ø �>Š>Û Ø=ˆDà#×.Ñ.Ø ™7ñ‰Eð ˜A‘wˆHÜ �H‰H�O‰O˜A˜rŸw™wŸ™¨xÓ8Ô 9Ü—‘˜hÔ'¨2ܘrŸw™w›y¨(°FÓ;�÷(ä×&Ñ&×1Ñ1°zÈ$Ø9Að2óCˆDð!Ø ŸK™KØ ŸI™IØ#Ø"ñ ˆEð Ü �4˜  g§o¡o°w·|±|Ô Dð €Mð ×ÑÔØ €M÷'(Ð'ûôò àŒCŒJÜ �H‰H�S—Y‘Y× Ð ð €Mûð  ús$Å:HÇ#H ÈHÈ IÈ)*IÉIr§rw)rÚimportlib.machineryrñrír«r0r˜Ú__all__rrrrrþrr rr Úrs]ðñ'ó$Û Û Û Ûâ &€÷#ñ#óN :óN÷~ñ~òD9ðx ˆzÒÙ…Fðr