How to use ctypes_oserror method in pytest-benchmark

Best Python code snippet using pytest-benchmark

time_monotonic.py

Source:time_monotonic.py Github

copy

Full Screen

...129 timespec_p = ctypes.POINTER(timespec)130 clock_gettime = library.clock_gettime131 clock_gettime.argtypes = (clockid_t, timespec_p)132 clock_gettime.restype = ctypes.c_int133 def ctypes_oserror():134 errno = ctypes.get_errno()135 message = os.strerror(errno)136 error_class = get_error_class(errno, OSError)137 return error_class(errno, message)138 def time_monotonic():139 ts = timespec()140 err = clock_gettime(time_monotonic.clk_id, ctypes.byref(ts))141 if err:142 raise ctypes_oserror()143 return ts.tv_sec + ts.tv_nsec * 1e-9144 if sys.platform.startswith("linux"):145 time_monotonic.clk_id = 1 # CLOCK_MONOTONIC146 elif sys.platform.startswith("freebsd"):147 time_monotonic.clk_id = 4 # CLOCK_MONOTONIC148 elif sys.platform.startswith("openbsd"):149 time_monotonic.clk_id = 3 # CLOCK_MONOTONIC150 else:151 assert sys.platform.startswith("sunos")152 time_monotonic.clk_id = 4 # CLOCK_HIGHRES153 def get_resolution():154 _clock_getres = library.clock_getres155 _clock_getres.argtypes = (clockid_t, timespec_p)156 _clock_getres.restype = ctypes.c_int157 ts = timespec()158 err = _clock_getres(time_monotonic.clk_id, ctypes.byref(ts))159 if err:160 raise ctypes_oserror()161 return ts.tv_sec + ts.tv_nsec * 1e-9162 time_monotonic_resolution = get_resolution()163 del get_resolution164else:...

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