Your IP : 216.73.216.218


Current Path : /lib/python3.9/test/libregrtest/__pycache__/
Upload File :
Current File : //lib/python3.9/test/libregrtest/__pycache__/win_utils.cpython-39.pyc

a

ؒd��@s\ddlZddlZddlZddlZddlZddlZdZde�ed�ZdZ	Gdd�d�Z
dS)�N��<�c@sheZdZdZdd�Zejejfdd�Z	e
je
je
jfdd�Zdd	d
�Zejejejfdd�Zd
d�ZdS)�WindowsLoadTrackerz�
    This class asynchronously reads the performance counters to calculate
    the system load on Windows.  A "raw" thread is used here to prevent
    interference with the test suite's cases for the threading module.
    cCsPt�tj�g|_d|_t�dddd�|_t�dddd�|_t	�
|jdi�dS)NTF�)�winregZQueryInfoKey�HKEY_PERFORMANCE_DATA�_values�_load�_overlappedZCreateEvent�_running�_stopped�_thread�start_new_thread�_update_load��selfrr�0/usr/lib/python3.9/test/libregrtest/win_utils.py�__init__szWindowsLoadTracker.__init__cCs$||jd�r|��q||j�dS)Ni�)r�_calculate_loadr
)r�_wait�_signalrrrr&s
zWindowsLoadTracker._update_loadcCs�||d�\}}|d|d�\}|d||�\}}||}	||}
|
|	kr�|d||
�\}}}
|
|7}
|dkr<|	|
}|d||�\}q�q<dS|jdur�|jt|dt|_n2t|j�tkr�|j�|�nt|j�t|j�|_dS)N�2�L�Z4xLLZLL28xL�,g�?)r
�
LOAD_FACTOR_1�lenr	�NVALUE�append�sum)rZ_queryZ_hkeyZ_unpack�data�_Z	obj_startZ
data_startZ
defn_startZ	data_baseZ	defn_base�size�idx�offsetZcounter_offsetZprocessor_queue_lengthrrrr0s(


�z"WindowsLoadTracker._calculate_loadTcCs|��dS�N)�__del__)r�killrrr�closehszWindowsLoadTracker.closecCsD|jdur@||j�||jd�||j�||j�d|_|_dS)N���)rr
)rrZ_closerrrrr'ls



zWindowsLoadTracker.__del__cCs|jSr&)r
rrrr�
getloadavg{szWindowsLoadTracker.getloadavgN)T)�__name__�
__module__�__qualname__�__doc__r�_winapiZWaitForSingleObjectrZSetEventrrZQueryValueExr�structZunpack_fromrr)ZCloseHandler'r+rrrrrs�
�
8
�
r)rrr0Zmathr1rZSAMPLING_INTERVALZexprrrrrrr�<module>s