Best Python code snippet using pytest-benchmark
clock_getres.py
Source:clock_getres.py
1import os2from virttest import error_context3from virttest import utils_test4from virttest import data_dir5@error_context.context_aware6def run(test, params, env):7 """8 Verify if guests using kvm-clock as the time source have a sane clock9 resolution.10 :param test: kvm test object.11 :param params: Dictionary with test parameters.12 :param env: Dictionary with the test environment.13 """14 vm = env.get_vm(params["main_vm"])15 vm.verify_alive()16 timeout = int(params.get("login_timeout", 360))17 session = vm.wait_for_login(timeout=timeout)18 getres_cmd = params.get("getres_cmd")19 if not getres_cmd or session.cmd_status("test -x %s" % getres_cmd):20 source_name = "clock_getres/clock_getres.c"21 source_name = os.path.join(data_dir.get_deps_dir(), source_name)22 getres_cmd = "/tmp/clock_getres"23 dest_name = "/tmp/clock_getres.c"24 if not os.path.isfile(source_name):25 test.error("Could not find %s" % source_name)26 vm.copy_files_to(source_name, dest_name)27 session.cmd("gcc -lrt -o %s %s" % (getres_cmd, dest_name))28 session.cmd(getres_cmd)29 test.log.info("PASS: Guest reported appropriate clock resolution")30 sub_test = params.get("sub_test")31 if sub_test:32 error_context.context("Run sub test '%s' after checking"33 " clock resolution" % sub_test, test.log.info)...
sqlite_promptt0.7000000000000001_pp1.0_fp2.0_20.py
Source:sqlite_promptt0.7000000000000001_pp1.0_fp2.0_20.py
...7# this file.8sqlite3.connect(':memory:').close()9libc = ctypes.CDLL(ctypes.util.find_library('c'))10# Test whether the system has clock_getres. If so, we can implement11# time.clock_getres().12try:13 libc.clock_getres14except AttributeError:15 has_clock_getres = False16else:17 has_clock_getres = True18# Test whether the system has clock_gettime. If so, we can implement19# time.clock_gettime().20try:21 libc.clock_gettime22except AttributeError:23 has_clock_gettime = False24else:25 has_clock_gettime = True...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!