Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/testing/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/testing/__pycache__/profiling.cpython-311.pyc

�

�܋f%"����dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZ	ddlZn
#e
$rdZYnwxYwdZdZGd�d	e��Zd
d�Zejdd���ZdS)z�Profiling support for unit and performance tests.

These are special purpose profiling methods which operate
in a more fine-grained way than nose's profiling plugin.

�N�)�config)�
gc_collect���update_wrapperc�R�eZdZdZd�Zed���Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
S)�ProfileStatsFilez�Store per-platform/fn profiling results in a file.

    We're still targeting Py2.5, 2.4 on 0.7 with no dependencies,
    so no json lib :(  need to roll something silly

    c���tjduotjj|_|jptjduotjj|_tj�|��|_	tj�
|j	��d|_tj
d���|_|���|jr|���dSdS)N���c�4�tjt��S�N)�collections�defaultdict�dict���o/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/sqlalchemy/testing/profiling.py�<lambda>z+ProfileStatsFile.__init__.<locals>.<lambda>8s��K�+�D�1�1�r)r�options�force_write_profiles�force_write�write_profiles�write�os�path�abspath�fname�split�short_fnamerr�data�_read�_write)�self�filenames  r�__init__zProfileStatsFile.__init__.s����N�$�&�N�6�>�+N�	
���%�
��N�$�&�H�6�>�+H�	
�
��W�_�_�X�.�.��
��7�=�=���4�4�R�8����+�1�1�
�
��	�	
�
�
�����:�	�
�K�K�M�M�M�M�M�	�	rc��tjjdztjjz}tjjdkr8tjj�tjj��r|dz
}d�d�tj	dd�D����}tj��tj���
��tj���
��||g}|�tjjjrdnd	��tj���}|�|rd
pd��d�|��S)N�_�sqlite�_file�.c�,�g|]}t|����Sr��str)�.0�vs  r�
<listcomp>z1ProfileStatsFile.platform_key.<locals>.<listcomp>Ks��E�E�E�!�s�1�v�v�E�E�Errr�
nativeunicode�dbapiunicode�cextensions�
nocextensions)r�db�name�driver�dialect�_is_url_file_db�url�join�sys�version_info�platform�machine�system�lower�python_implementation�append�convert_unicode�requirements�_has_cextensions)r$�	dbapi_key�
py_version�platform_tokens�	_has_cexts     r�platform_keyzProfileStatsFile.platform_key@sG���I�N�S�(�6�9�+;�;�	��9�>�X�%�%�&�)�*;�*K�*K��I�M�+
�+
�%�
�� �I��X�X�E�E�s�/?��!��/D�E�E�E�F�F�
�
�����O���#�#�%�%��*�,�,�2�2�4�4���
��	����y� �0�
 �O�O��	
�	
�	
�
�'�8�8�:�:�	����y�:�]�M�o�N�N�N��x�x��(�(�(rc�J�t}||jvo|j|j|vSr)�
_current_testr!rL)r$�test_keys  r�	has_statszProfileStatsFile.has_stats^s*�� ����	�!�N�d�&7�4�9�X�;N�&N�	
rc�h�t}|j|}||j}d|vrgx|d<}n|d}d|vrdx|d<}n|d}t|��|k}|s3|�|��|jr|���d}n|d||f}|dxxdz
cc<|S)N�counts�
current_countr�linenor)rNr!rL�lenrDrr#)	r$�	callcountrO�per_fn�per_platformrRrS�	has_count�results	         rrZzProfileStatsFile.resultds��� ����8�$���d�/�0���<�'�'�.0�0�L��"�V�V�!�(�+�F��,�.�.�<=�=�L��)�M�M�(��9�M���K�K�-�/�	��	C��M�M�)�$�$�$��z�
����
�
�
��F�F�!�(�+�V�M�-B�B�F��_�%�%�%��*�%�%�%��
rc���t}|j|}||j}|d}|d}|t|��kr	|||dz
<n||d<|jr|���dSdS)NrRrSrr)rNr!rLrUrr#)r$rVrOrWrXrRrSs       r�replacezProfileStatsFile.replaces��� ����8�$���d�/�0���h�'��$�_�5�
��3�v�;�;�&�&�(1�F�=�1�$�%�%�"�F�2�J��:�	��K�K�M�M�M�M�M�	�	rc��d|jzS)Na
# %s
# This file is written out on a per-environment basis.
# For each test in aaa_profiling, the corresponding function and 
# environment is located within this file.  If it doesn't exist,
# the test is skipped.
# If a callcount does exist, it is compared to what we received. 
# assertions are raised if the counts do not match.
# 
# To add a new callcount test, apply the function_call_count 
# decorator and re-run the tests using the --write-profiles 
# option - this file will be rewritten including the new count.
# 
)r)r$s r�_headerzProfileStatsFile._header�s��
��Z�!�	rc��	t|j��}n#t$rYdSwxYwt|��D]�\}}|���}|r|�d��r�1|���\}}}|j|}||}d�|�d��D��}	|	|d<|dz|d<d|d<��|���dS)	N�#c�,�g|]}t|����Sr)�int�r/�counts  rr1z*ProfileStatsFile._read.<locals>.<listcomp>�s��;�;�;���U���;�;�;r�,rRrrTrrS)	�openr�IOError�	enumerate�strip�
startswithrr!�close)
r$�	profile_frT�linerOrLrRrWrX�cs
          rr"zProfileStatsFile._read�s��	��T�Z�(�(�I�I���	�	�	��F�F�	����%�i�0�0�	.�	.�L�F�D��:�:�<�<�D��
�4�?�?�3�/�/�
��-1�Z�Z�\�\�*�H�l�F��Y�x�(�F�!�,�/�L�;�;����c�):�):�;�;�;�A�%&�L��"�%+�a�Z�L��"�,-�L��)�)��������s��
%�%c
��td|jz��t|jd��}|�|�����t|j��D]�}|j|}|�d|z��t|��D]M}||}d�d�|dD����}|�|�d|�d|�d����N��|���dS)	NzWriting profile file %s�wz
# TEST: %s

rec3�4K�|]}t|��V��dSrr-rcs  r�	<genexpr>z*ProfileStatsFile._write.<locals>.<genexpr>�s(����L�L�E�S��Z�Z�L�L�L�L�L�LrrR� �
)	�printrrfrr^�sortedr!r<rk)r$rlrOrWrLrXrns       rr#zProfileStatsFile._write�s��
�(�4�:�5�7�7�7����S�)�)�	���������'�'�'��t�y�)�)�	L�	L�H��Y�x�(�F��O�O�.��9�:�:�:� &�v���
L�
L��%�l�3���H�H�L�L�\�(�5K�L�L�L�L�L��������,�,�,���� J�K�K�K�K�
L�	�������rN)
�__name__�
__module__�__qualname__�__doc__r&�propertyrLrPrZr\r^r"r#rrrr
r
&s������������$�)�)��X�)�:
�
�
����6������&���&����rr
皙�����?c��������fd�}|S)a�Assert a target for a test case's function call count.

    The main purpose of this assertion is to detect changes in
    callcounts for various functions - the actual number is not as important.
    Callcounts are stored in a file keyed to Python version and OS platform
    information.  This file is generated automatically for new tests,
    and versioned so that unexpected changes in callcounts will be detected.

    c�6�������fd�}t|���S)Nc����t�	��D]
}�|i|���t���}t����5|D]
}�|i|��}�|cddd��S#1swxYwYdS)N)�variance)�range�count_functions)
�args�kw�warm�	timerange�time�rv�fn�timesr��warmups
      ����r�wrapz3function_call_count.<locals>.decorate.<locals>.wrap�s�����f�
�
�
 �
 ����D��B������e���I� �(�3�3�3�
�
�%�)�)�D���T��R���B�B��
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�A�A�Ar)r�r�r�r�r�s` ���r�decoratez%function_call_count.<locals>.decorate�s>����	�	�	�	�	�	�	�	��d�B�'�'�'rr)r�r�r�r�s``` r�function_call_countr��s/�����
(�
(�
(�
(�
(�
(�
(��Orc#�K�t�tjd���t���s-tjs!tjdtjz��t��tj	��}|�
��dV�|���tj
|tj���}|j}t�|��}|�d}n|\}}t%d||fz��|�d��|���|r�t+||z��}t-||z
��|k}|stjrStjrt�|��dSt3d|�d|dz�d	|�d
tj�d�	���dSdS)NzcProfile is not installedz�No profiling stats available on this platform for this function.  Run tests with --write-profiles to add statistics to %s for this platform.)�streamzPstats calls: %d Expected %s�
cumulativezAdjusted function call count z not within �dz% of expected z, platform z;. Rerun with --write-profiles to regenerate this callcount.)�cProfiler�_skip_test_exception�_profile_statsrPr�	skip_testr r�Profile�enable�disable�pstats�Statsr=�stdout�total_callsrZru�
sort_stats�print_statsrb�absrr\�AssertionErrorrL)	r��pr�statsrV�expected�expected_count�line_no�deviance�faileds	         rr�r��s��������)�*E�F�F�F��#�#�%�%�
�n�.B�
���
� .�9�
:�	
�	
�	
��L�L�L�	�	�	�	�B��I�I�K�K�K�	�E�E�E��J�J�L�L�L�
�L��C�J�/�/�/�E��!�I��$�$�Y�/�/�H������"*����	�)�Y��,G�G�I�I�I�	���\�"�"�"�	���������y�8�+�,�,���Y��/�0�0�8�;���	�^�/�	��#�
��&�&�y�1�1�1�1�1�$�n�"�	�	�!�C����&���&�3�3�3�	������	�	r)r|rr)r|)rzr�
contextlibrr?r�r=�r�utilrrr��ImportErrorrNr��objectr
r��contextmanagerr�rrr�<module>r�s:������������	�	�	�	�����
�
�
�
�
�
�
�
�������������!�!�!�!�!�!���O�O�O�O�������H�H�H������
���X�X�X�X�X�v�X�X�X�v����4��9�9�9���9�9�9s�3�=�=

Hacked By AnonymousFox1.0, Coded By AnonymousFox