How to use clock_gettime method in pytest-benchmark

Best Python code snippet using pytest-benchmark

realtime.py

Source:realtime.py Github

copy

Full Screen

...23CLOCK_BOOTTIME = 724if platform.system() != 'Darwin' and hasattr(libc, 'clock_gettime'):25 c_clock_gettime = libc.clock_gettime26 tlocal = threading.local()27 def clock_gettime(clk_id):28 if not hasattr(tlocal, 'ts'):29 tlocal.ts = ffi.new('struct timespec *')30 ts = tlocal.ts31 r = c_clock_gettime(clk_id, ts)32 if r != 0:33 raise OSError("clock_gettime")34 return ts.tv_sec + ts.tv_nsec * 1e-935else:36 # hack. only for OS X < 10.1237 def clock_gettime(clk_id):38 return time.time()39def monotonic_time():40 return clock_gettime(CLOCK_MONOTONIC_RAW)41def sec_since_boot():42 return clock_gettime(CLOCK_BOOTTIME)43def set_realtime_priority(level):44 if os.getuid() != 0:45 print("not setting priority, not root")46 return47 if platform.machine() == "x86_64":48 NR_gettid = 18649 elif platform.machine() == "aarch64":50 NR_gettid = 17851 else:52 raise NotImplementedError53 tid = libc.syscall(NR_gettid)54 return subprocess.call(['chrt', '-f', '-p', str(level), str(tid)])55class Ratekeeper(object):56 def __init__(self, rate, print_delay_threshold=0.):...

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