How to use ctypes_winerror method in pytest-benchmark

Best Python code snippet using pytest-benchmark

pep418.py

Source:pep418.py Github

copy

Full Screen

...55 LARGEINTEGER = ctypes.c_int6456 LARGEINTEGER_p = POINTER(LARGEINTEGER)57 FILETIME_p = POINTER(FILETIME)58 ULONGLONG = ctypes.c_uint6459 def ctypes_winerror():60 errno = ctypes.get_errno()61 message = os.strerror(errno)62 return WindowsError(errno, message)63 _QueryPerformanceFrequency = windll.kernel32.QueryPerformanceFrequency64 _QueryPerformanceFrequency.restype = BOOL65 _QueryPerformanceFrequency.argtypes = (LARGEINTEGER_p,)66 def QueryPerformanceFrequency():67 frequency = LARGEINTEGER()68 ok = _QueryPerformanceFrequency(byref(frequency))69 if not ok:70 raise ctypes_winerror()71 return int(frequency.value)72 _QueryPerformanceCounter = windll.kernel32.QueryPerformanceCounter73 _QueryPerformanceCounter.restype = BOOL74 _QueryPerformanceCounter.argtypes = (LARGEINTEGER_p,)75 def QueryPerformanceCounter():76 frequency = LARGEINTEGER()77 ok = _QueryPerformanceCounter(byref(frequency))78 if not ok:79 raise ctypes_winerror()80 return int(frequency.value)81 GetTickCount = windll.kernel32.GetTickCount82 GetTickCount.restype = DWORD83 GetTickCount.argtypes = ()84 if hasattr(windll.kernel32, 'GetTickCount64'):85 GetTickCount64 = windll.kernel32.GetTickCount6486 GetTickCount64.restype = ULONGLONG87 GetTickCount64.argtypes = ()88 has_GetTickCount64 = True89 GetCurrentProcess = windll.kernel32.GetCurrentProcess90 GetCurrentProcess.argtypes = ()91 GetCurrentProcess.restype = HANDLE92 _GetProcessTimes = windll.kernel32.GetProcessTimes93 _GetProcessTimes.argtypes = (HANDLE, FILETIME_p, FILETIME_p, FILETIME_p, FILETIME_p)94 _GetProcessTimes.restype = BOOL95 def filetime2py(obj):96 return (obj.dwHighDateTime << 32) + obj.dwLowDateTime97 def GetProcessTimes(handle):98 creation_time = FILETIME()99 exit_time = FILETIME()100 kernel_time = FILETIME()101 user_time = FILETIME()102 ok = _GetProcessTimes(handle,103 byref(creation_time), byref(exit_time),104 byref(kernel_time), byref(user_time))105 if not ok:106 raise ctypes_winerror()107 return (filetime2py(creation_time), filetime2py(exit_time),108 filetime2py(kernel_time), filetime2py(user_time))109 _GetSystemTimeAsFileTime = windll.kernel32.GetSystemTimeAsFileTime110 _GetSystemTimeAsFileTime.argtypes = (FILETIME_p,)111 _GetSystemTimeAsFileTime.restype = None112 def GetSystemTimeAsFileTime():113 system_time = FILETIME()114 _GetSystemTimeAsFileTime(byref(system_time))115 return filetime2py(system_time)116 libc_name = ctypes.util.find_library('c')117 if libc_name:118 libc = ctypes.CDLL(libc_name, use_errno=True)119 clock_t = ctypes.c_ulong120 if sys.platform == 'darwin':...

Full Screen

Full Screen

4a91107d34c429454e341349d8e18063_pep418.py

Source:4a91107d34c429454e341349d8e18063_pep418.py Github

copy

Full Screen

...49 LARGEINTEGER = ctypes.c_int6450 LARGEINTEGER_p = POINTER(LARGEINTEGER)51 FILETIME_p = POINTER(FILETIME)52 ULONGLONG = ctypes.c_uint6453 def ctypes_winerror():54 errno = ctypes.get_errno()55 message = os.strerror(errno)56 return WindowsError(errno, message)57 _QueryPerformanceFrequency = windll.kernel32.QueryPerformanceFrequency58 _QueryPerformanceFrequency.restype = BOOL59 _QueryPerformanceFrequency.argtypes = (LARGEINTEGER_p,)60 def QueryPerformanceFrequency():61 frequency = LARGEINTEGER()62 ok = _QueryPerformanceFrequency(byref(frequency))63 if not ok:64 raise ctypes_winerror()65 return int(frequency.value)66 _QueryPerformanceCounter = windll.kernel32.QueryPerformanceCounter67 _QueryPerformanceCounter.restype = BOOL68 _QueryPerformanceCounter.argtypes = (LARGEINTEGER_p,)69 def QueryPerformanceCounter():70 frequency = LARGEINTEGER()71 ok = _QueryPerformanceCounter(byref(frequency))72 if not ok:73 raise ctypes_winerror()74 return int(frequency.value)75 GetTickCount = windll.kernel32.GetTickCount76 GetTickCount.restype = DWORD77 GetTickCount.argtypes = ()78 if hasattr(windll.kernel32, 'GetTickCount64'):79 GetTickCount64 = windll.kernel32.GetTickCount6480 GetTickCount64.restype = ULONGLONG81 GetTickCount64.argtypes = ()82 has_GetTickCount64 = True83 GetCurrentProcess = windll.kernel32.GetCurrentProcess84 GetCurrentProcess.argtypes = ()85 GetCurrentProcess.restype = HANDLE86 _GetProcessTimes = windll.kernel32.GetProcessTimes87 _GetProcessTimes.argtypes = (HANDLE, FILETIME_p, FILETIME_p, FILETIME_p, FILETIME_p)88 _GetProcessTimes.restype = BOOL89 def filetime2py(obj):90 return (obj.dwHighDateTime << 32) + obj.dwLowDateTime91 def GetProcessTimes(handle):92 creation_time = FILETIME()93 exit_time = FILETIME()94 kernel_time = FILETIME()95 user_time = FILETIME()96 ok = _GetProcessTimes(handle,97 byref(creation_time), byref(exit_time),98 byref(kernel_time), byref(user_time))99 if not ok:100 raise ctypes_winerror()101 return (filetime2py(creation_time), filetime2py(exit_time),102 filetime2py(kernel_time), filetime2py(user_time))103 _GetSystemTimeAsFileTime = windll.kernel32.GetSystemTimeAsFileTime104 _GetSystemTimeAsFileTime.argtypes = (FILETIME_p,)105 _GetSystemTimeAsFileTime.restype = None106 def GetSystemTimeAsFileTime():107 system_time = FILETIME()108 _GetSystemTimeAsFileTime(byref(system_time))109 return filetime2py(system_time)110 libc_name = ctypes.util.find_library('c')111 if libc_name:112 libc = ctypes.CDLL(libc_name, use_errno=True)113 clock_t = ctypes.c_ulong114 if sys.platform == 'darwin':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-benchmark automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful