Rh?ddlZddlZddlZddlZddlZddlZdZdejedz z ZdZ GddZ y)N<ceZdZdZdZej ejfdZ e je je jfdZd dZej ej"ejfdZdZy) 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. c8d|_d|_tjtjg|_d|_tjdddd|_tjdddd|_tj|jdiy)NTF) _running_stoppedwinreg QueryInfoKeyHKEY_PERFORMANCE_DATA_values_load _overlapped CreateEvent_threadstart_new_thread _update_loadselfs 1/usr/lib/python3.12/test/libregrtest/win_utils.py__init__zWindowsLoadTracker.__init__s|   F889  #//dE4H #//dE4H   !2!2B;c||jdr$|j||jdr$||jy)Ni)r _calculate_loadr )r_wait_signals rrzWindowsLoadTracker._update_load*s< DMM4(  "DMM4(  rc||d\}}|d|d\}|d||\}}||z} ||z} | | kr0|d|| \} } } | | z } | dk(r| | z}|d||\}n| | kr0y|j&|jtz|dtz zz|_yt|jtkr|jj |yt |jt|jz |_y)N2L4xLLLL28xL,g?)r LOAD_FACTOR_1lenrNVALUEappendsum)r_query_hkey_unpackdata_ obj_start data_start defn_start data_base defn_basesizeidxoffsetcounter_offsetprocessor_queue_lengths rrz"WindowsLoadTracker._calculate_load4s $aS$+ ")y!A J *  * )#!($ B D#v  Iby!*V!3*1#t^*L'&)#  :: !**}44}9LMNDJ   ' LL   6 7T\\*S->>DJrc$|jyN)__del__)rkills rclosezWindowsLoadTracker.closels rc|jX||j||jd||j||jdx|_|_yy)N)r r )rr_closers rr<zWindowsLoadTracker.__del__psS == $ DMM " $-- $ 4== ! 4== !,0 0DMDM %rc|jSr;)rrs r getloadavgzWindowsLoadTracker.getloadavgs zzrN)T)__name__ __module__ __qualname____doc__r_winapiWaitForSingleObjectrSetEventrr QueryValueExrstruct unpack_fromrr> CloseHandler<rCr rrrrst <$#66(11 &22$:: & 2 2 6?p 11**#,, 1rr) rrrHmathrLr SAMPLING_INTERVALexpr&r(rr rrrRsO HDHH.344  mmr