Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
profile.cpython-314.pyc198 linesDownload Raw Back to __pycache__
1+
2��iLZ���Rt^RIt^RIt^RIt^RIt^RIt.R3Ot!RR4tRRlt	RRlt4!RR4tRt]
R	8Xd5]!4R#R#)z Class for profiling Python code.N�Profilec�<a�]tRt^*toRtRtRtRtRtRt	Vt6R#)�_Utilsz~Support class for utility functions which are shared by7profile.py and cProfile.py modules.8Not supposed to be used directly.9c��WnR#�N��profiler)�selfrs&&�Lib\profile.py�__init__�_Utils.__init__0s�� �
�c��VP4pVPV4VPWBV4R# \dL!i;i TPYBT4i;ir)r�run�10SystemExit�_show)r	�	statement�filename�sort�profs&&&& r11r�12_Utils.run3sS���}�}���	-��H�H�Y��
�J�J�t�t�,���	��	��
�J�J�t�t�,�s!�7�A�A�A�A�Ac���VP4pVPWV4VPWdV4R# \dL!i;i TPYdT4i;ir)r�runctxrr)r	r�globals�localsrrrs&&&&&& r13r�
_Utils.runctx<sU���}�}���	-��K�K�	�F�3�
�J�J�t�t�,���	��	��
�J�J�t�t�,�s!�8�A�A	�A�A	�	Ac�V�VeVPV4R#VPV4R#r)�14dump_stats�print_stats)r	rrrs&&&&r15r�_Utils._showEs"�����O�O�H�%����T�"r
rN)�__name__�16__module__�__qualname__�__firstlineno__�__doc__rrrr�__static_attributes__�__classdictcell__��
__classdict__s@r17rr*s#�����18!�-�-�#�#r
rc�@�\\4PWV4#)a�Run statement under profiler optionally saving results in filename19 20This function takes a single argument that can be passed to the21"exec" statement, and an optional file name.  In all cases this22routine attempts to "exec" its first argument and gather profiling23statistics from the execution. If no file name is present, then this24function automatically prints a simple profiling report, sorted by the25standard name string (file/line/function-name) that is presented in26each line.27)rrr)rrrs&&&r28rrQs���'�?���y�D�9�9r
c�B�\\4PWW#V4#)z�Run statement under profiler, supplying your own globals and locals,29optionally saving results in filename.30 31statement and filename have the same semantics as profile.run32)rrr)rrrrrs&&&&&r33rr^s���'�?�!�!�)�f��M�Mr
c��a�]tRt^gtoRt^tR#RltRtRtRt	Rt34RtR	tR35t
RtR]R
]R]R]
R]R]/tRt!RR4t!RR4tRtRtR$RltRtRtRtRtRtRtR%R ltR!tR"tVtR#)&ra�Profiler class.36 37self.cur is always a tuple.  Each such tuple corresponds to a stack38frame that is currently active (self.cur[-2]).  The following are the39definitions of its members.  We use this external "parallel stack" to40avoid contaminating the program that we are profiling. (old profiler41used to write into the frames local dictionary!!) Derived classes42can change the definition of some entries, as long as they leave43[-2:] intact (frame and previous tuple).  In case an internal error is44detected, the -3 element is used as the function name.45 46[ 0] = Time that needs to be charged to the parent frame's function.47       It is used so that a function call will not have to access the48       timing data for the parent frame.49[ 1] = Total time spent in this frame's function, excluding time in50       subfunctions (this latter is tallied in cur[2]).51[ 2] = Total time spent in subfunctions, excluding time executing the52       frame's function (this latter is tallied in cur[1]).53[-3] = Name of the function that corresponds to this frame.54[-2] = Actual frame that we correspond to (used to sync exception handling).55[-1] = Our parent 6-tuple (corresponds to frame.f_back).56 57Timing data for each function is stored as a 5-tuple in the dictionary58self.timings[].  The index is always the name stored in self.cur[-3].59The following are the definitions of the members:60 61[0] = The number of times this function was called, not counting direct62      or indirect recursion,63[1] = Number of times this function appears on the stack, minus one64[2] = Total time spent internal to this function65[3] = Cumulative time that this function was present on the stack.  In66      non-recursive functions, this is the total execution time from start67      to finish of each invocation of a function, including time spent in68      all subfunctions.69[4] = A dictionary indicating for each function name, the number of times70      it was called by us.71Nc�,�/VnRVnRVnRVnVf
VPpW nV'g/\72P;VnVnVPVn73M]WnVP4p\V4pV^8XdVPVn74MVPVn75V\3RlpWPnVP4VnVP#R4R# \dYnTPTn76LLi;i)N�c��V!V!44#r�)�timer�sums&&r77�get_time_timer�(Profile.__init__.<locals>.get_time_timer�s���u�w�<�'r
r)�timings�cur�cmd�c_func_name�bias�time�process_timer0�get_time�trace_dispatch_i�78dispatcher�len�trace_dispatch�trace_dispatch_lr1�	TypeError�t�
simulate_call)r	r0r8rB�lengthr2s&&&   r79r�Profile.__init__�s����������������<��9�9�D��	��)-�):�):�:�D�J���"�3�3�D�O��J��80�81��A�
/��Q���82�Q�;�&*�&9�&9�D�O�&*�&;�&;�D�O�*/�C�(� .�
����������:�&��#�
8� %�
�"&�"7�"7���
8�s�C.�."D�Dc��VPpV!4pV^,V^,,VP,83VP,84pVR8XdVPVnVP85V,!WV4'd&V!4pV^,V^,,VnR#V!4pV^,V^,,V,86VnR#)��c_callN�r0rBr8r r7�dispatch)r	�frame�event�argr0rB�rs&&&&   r87r?�Profile.trace_dispatch�s����88�89���G��
�a�D�1�Q�4�K�$�&�&� �4�9�9�,���H��"�|�|�D���=�=����A�.�.���A��q�T�A�a�D�[�D�F���A��q�T�A�a�D�[�1�_�D�Fr
c�"�VPpV!4VP,90VP,91pVR8XdVPVnVP92V,!WV4'dV!4VnR#V!4V,93VnR#�rHNrI�r	rKrLrMr0rBs&&&&  r94r<�Profile.trace_dispatch_i�sd���95�96���G�d�f�f��t�y�y�(���H��"�|�|�D���=�=����Q�/�/��W�D�F��W�q�[�D�Fr
c�L�VPpV!4R,VP,97VP,98pVR8XdVPVnVP99V,!WV4'dV!4R,VnR#V!4R,V,100VnR#)gN@rHNrIrRs&&&&  r101�trace_dispatch_mac�Profile.trace_dispatch_mac�sq���102�103���G�D�L�4�6�6�!�D�I�I�-���H��"�|�|�D���=�=����Q�/�/��W�T�\�D�F��W�T�\�A�%�D�Fr
c�"�VPpV!4VP,104VP,105pVR8XdVPVnVP106V,!WV4'dV!4VnR#V!4V,107VnR#rQ)r;rBr8r r7rJ)r	rKrLrMr;rBs&&&&  r108r@�Profile.trace_dispatch_l�sd���=�=���J�����$�)�)�+���H��"�|�|�D���=�=����Q�/�/��Z�D�F��Z�!�^�D�Fr
c��VPwr4rVrxWqJdV'dVPWr4#W4V,WVWx3Vn^#)�)r5�trace_dispatch_return)	r	rKrB�rpt�rit�ret�rfn�rframe�rcurs	&&&      r109�trace_dispatch_exception� Profile.trace_dispatch_exception�s@��+/�8�8�(��#�F���T��-�-�f�8�8��A��s��5���r
c���VP'd�VPVPR,Jd�VPwr4rVrx\V\P4'g�VPVPJg QRVWwPWP34hVPV^4VPe<VPVPR,JgQRVPR,34hVPp	V	PV	PV	P3p110V^^W�VP3VnVPpW�9dW�,wr�r�pW�^,W�V3W�&^#^^^^/3W�&^#)�zBad call����������)r5�f_back�111isinstancer�112fake_framer[�f_code�co_filename�co_firstlineno�co_namer4)r	rKrBr\r]r^r_r`ra�fcode�fnr4�cc�ns�tt�ct�callerss&&&              r113�trace_dispatch_call�Profile.trace_dispatch_callsS���8�8�8����D�H�H�R�L�8�/3�x�x�,�C�c���f�g�&8�&8�9�9��}�}����4�L�z�3�7=�}�}�7<�l�l�7L�L�4��*�*�6�1�5����(���������4�F�8B�8<�����8F�F�5���������!5�!5�u�}�}�
E���q�!�R����1����,�,��
�=�&-�k�#�B�B�G��1�f�b�g�5�G�K���Q��1�b�.�G�K�r
c��R^VP3pV^^W1VP3VnVPpW49dWC,wrVrxp	WV^,WxV	3WC&^#^^^^/3WC&^#)r-)r7r5r4)114r	rKrBrpr4rqrrrsrtrus115&&&       r116�trace_dispatch_c_call�Profile.trace_dispatch_c_callss���!�T�%�%�
&���q�!�R����1����,�,��
�=�&-�k�#�B�B�G���d�B�G�3�G�K���Q��1�b�.�G�K�r
c�>�WPR,Jd^WPR,PJgQRVPR,34hVPVPR,^4VPwr4rVrWB,pWE,pVwr�r�r�W�V,W�,W�V3VnVPpW�,wpppppV'gVV,pV^,pVV9dVV,^,VV&M^VV&VV^,117VV,VV3W�&^#)rez118Bad returnrfrg)r5rhr[r4)r	rKrBr\r]r^r_ra�frame_total�ppt�pit�pet�pfn�pframe�pcurr4rqrrrsrtrus&&&                  r119r[�Profile.trace_dispatch_return"s�������$��H�H�R�L�/�/�/�M�,������1M�M�/��&�&�t�x�x��|�Q�7�120+/�(�(�'��#�E��g���i��+/�(��#�F��c�	�3�#4�c�4�G����,�,��")�,���B��B���121�k�!�B��a��B��'�>�"�3�<�!�+�G�C�L�122�G�C�L��2��6�2��8�R��8���r
�call�	exception�returnrH�c_exception�c_returnc�j�VPR,'dR#WnVPV4R#)rZN�����)r5r6rC)r	r6s&&r123�set_cmd�Profile.set_cmdXs$���8�8�B�<�<�������3�r
c�,a�]tRtRtoRtRtRtVtR#)�Profile.fake_codei]c�8�WnW nW0n^VnR#�rGN)rl�co_linernrm)r	r�line�names&&&&r124r�Profile.fake_code.__init__^s��'���L��L�"#�D�r
c�Z�\VPVPVP34#r)�reprrlr�rn�r	s&r125�__repr__�Profile.fake_code.__repr__ds"����)�)�4�<�<����F�G�Gr
)rlrmr�rnN)r r!r"r#rr�r%r&r's@r126�	fake_coder�]s����	$�	H�	Hr
r�c�&a�]tRtRtoRtRtVtR#)�Profile.fake_frameigc��WnW nR#r)rkrh)r	�code�priors&&&r127r�Profile.fake_frame.__init__hs���K��Kr
)rhrkN)r r!r"r#rr%r&r's@r128rjr�gs����	 �	 r
rjc���VPR^V4pVP'dVPR,pMRpVPW#4pVPR,!W^4R#)�profileNr�rf)r�r5rjrJ)r	r�r�r�rKs&&   r129rC�Profile.simulate_calllsP���~�~�i��D�1���8�8�8��X�X�b�\�F��F�����-���
�
�f��d�1�-r
c��VPpV!4VP,130pVPR,'d0VPR,!WPR,V4^pKHV!4V,131VnR#)rZr�Nr�rf)r;rBr5rJ)r	r;rBs&  r132�simulate_cmd_complete�Profile.simulate_cmd_completexsW���=�=���J�������h�h�r�l�l�
�M�M�(�#�D�(�(�2�,��:��A���a���r
c��^RIp\V\4'gV3pVPV4P	4P133!V!P
4R#r�)�pstatsri�tuple�Stats�134strip_dirs�135sort_statsr)r	rr�s&& r136r�Profile.print_stats�sB����$��&�&��7�D����T��%�%�'�2�2�D�9�E�E�Gr
c���\VR4;_uu_4pVP4\P!VPV4RRR4R# +'giR#;i)�wbN)�open�create_stats�marshal�dump�stats)r	�file�fs&& r137r�Profile.dump_stats�s>��
�$��
�
�������L�L����Q�'��
�
�
�s�2A�A"	c�F�VP4VP4R#r)r��snapshot_statsr�s&r138r��Profile.create_stats�s���"�"�$����r
c���/VnVPP4FMwpwr#rEpVP4p^pVP	4FpWx,
pK
	W'WEV3VPV&KO	R#r�)r�r4�items�copy�values)	r	�funcrqrrrsrtru�nc�callcnts	&        r139r��Profile.snapshot_stats�sj����140�/3�|�|�/A�/A�/C�+�D�+�2�2�7��l�l�n�G��B�"�>�>�+���
��,�!�r�w�6�D�J�J�t��0Dr
c�F�^RIpVPpVPWV4#r�)�__main__�__dict__r)r	r6r��dicts&&  r141r�Profile.run�s!���� � ���{�{�3�d�+�+r
c���VPV4\P!VP4\	WV4\P!R4V# \P!R4i;ir)r��sys�142setprofiler=�exec)r	r6rrs&&&&r143r�Profile.runctx�sN�����S�����t���'�	!���v�&��N�N�4� ����
�N�N�4� �s�A�A/c���VP\V44\P!VP4V!V/VB\P!R4# \P!R4i;ir)r�r�r�r�r=)r	r��args�kws""*,r144�runcall�Profile.runcall�sM�����T�$�Z� ����t���'�	!���$��$��N�N�4� ��C�N�N�4� �s�A�A2c��VP\Jd\R4hVPp^VnVP	W4W0n# Y0ni;i)z&Subclasses must override .calibrate().)�	__class__rrAr8�_calibrate_inner)r	�m�verbose�145saved_biass&&& r146�	calibrate�Profile.calibrate�sH���>�>��(��D�E�E��Y�Y�147���	�	#��(�(��4�"�I��148�I�s�A�Ac��VPpRpV3RlpV!V4V!4pV!V4V!4pWv,149pV'd
\RV4\4p	V!4pV	PR\	4\44V!4pWv,150p151V'd
\RV1524RpRpV	PP4F*wwr�pwpppppVR9gKVV,
pVV,
pK,	V'd\RV4\RV4W�^,8wd\RV,4hW�,153R	,V,pV'd
\R154V4V#)c�.�\V4Fp^pK	R#)rZN��range)�n�i�xs&  r155�f1�$Profile._calibrate_inner.<locals>.f1�s���1�X����r
c�:�\V4FpV!^d4K
	R#)�dNr�)r�r�r�s&& r156r��#Profile._calibrate_inner.<locals>.f�s���1�X���3��r
z elapsed time without profiling =zf(m)zelapsed time with profiling =gz!'CPU seconds' profiler reported =ztotal # calls =z internal error: total calls = %dg@z+mean stopwatch overhead per profile event =)r�r�)	r;�printrrrrr4r��157ValueError)r	r�r�r;r�r��t0�t1�elapsed_noprofile�p�elapsed_profile�total_calls�
reported_timerr��funcnamerqrrrsrtru�means&&&                   r158r��Profile._calibrate_inner�sC���=�=��	��	�	159�!���Z��	�!��
�Z���G����4�6G�H�160
�I��
�Z��	������F�H�-�
�Z���'����1�?�C����
��	�	���!�
B�&�X�X�(A��R��R���;�&��r�!����#�
�"�161��5�}�E��#�[�1��a�%���?�+�M�N�N��1�S�8�;�F����?��F��r
)162r8r7r6r5r=r;r�rBr0r4)NN)r�)rG) r r!r"r#r$r8rr?r<rUr@rbrvryr[rJr�r�rjrCr�rrr�r�rrr�r�r�r%r&r's@r163rrgs�����$�L
�D�#'�N
%�$164!�165&�166$�&��,	�#�N	�#��-��'��'��,��)�
167�H�  �168H�H� � �169.� �H�(�170�7�,�171�!�b	#�<�<r
c172�*�^RIp^RIHpRpV!VR7pRVnVP	RRRR	RR1737VP	RRR
RRR7VP	RRRRR!R1747\175PR,'g'VP4\176P!^4VP4wrEV\177PR&VPe+VPPVP4Vn178\V4^8�EdVP'd^RIpRpRVP RV^,/pM�V^,p	\179PP#^VPP%V	44\&P(!V	4;_uu_4p180\+V181P-4V	R4pRRR4\.P0P3RRV	R7pRVRVP4RVP6RRR R/p\9XVRVPVP:4V#VP4V# +'giL�;i \<d7pR\182n\183P!TP@4Rp?T#Rp?ii;i)"rGN)�OptionParserzMprofile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...)�usageFz-oz	--outfile�outfilezSave stats to <outfile>)�dest�help�defaultz-m�module�184store_truezProfile a library module.)r��actionr�r�z-sz--sortrz?Sort order when printing to stdout, based on pstats.Stats class:rZNN:NNNz(run_module(modname, run_name='__main__')�185run_module�modnamer�r�)r��loader�origin�__spec__�__file__r �__package__�186__cached__r�)!�os�optparser��allow_interspersed_args�187add_optionr��argv�print_usage�exit�188parse_argsr��path�abspathr>r��runpyr��insert�dirname�io�	open_code�compile�read�	importlib�	machinery�189ModuleSpecr�r�rr�BrokenPipeError�stdout�errno)
rr�r��parser�optionsr�rr��globs�progname�fp�spec�excs
             r190�mainr"*s+��
�%�[�E�
��
&�F�%*�F�"�191���d�K�i�
&���6�192���d��,�
(�%��9�193���d�H�6�
N�����8�8�B�<�<�����������'�'�)�O�W��C�H�H�Q�K����"��'�'�/�/�'�/�/�:���194�4�y�1�}��>�>�>��=�D��e�.�.��4��7��E�195�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��D��D�K�K��D�I�I��t��d��E�	 ��4���g�o�o�w�|�|�D��M�	�����M�'(�'���	 ��C�J��H�H�S�Y�Y����M��
	 �s$� H>�#I�>I	�J�+J
�
Jr�)rrr)Nr�)r$�importlib.machineryrrr�r9r��__all__rrrrr"r r/r
r196�<module>r%s]��'�$�	�197���198&��#�#�N:�N���F9�x�z���F�r
codekingpro/portable-devtools · Team Ai