Best Python code snippet using pytest-benchmark
calc_interene.py
Source: calc_interene.py
...6import argparse7import numpy as np8from sgenlib import pdb9from sgenlib import parsing10def _make_stats(data) :11 mean = data.mean()12 std = data.std()/np.sqrt(data.shape[0])13 nhalf = int(0.5*data.shape[0])14 drift = np.abs(data[:nhalf].mean() - data[nhalf:].mean())15 return "%.3f\t%.3f\t%.3f"%(mean, std, drift),[mean, std, drift]16if __name__ == '__main__' :17 # Command-line input18 parser = argparse.ArgumentParser(description="Calculate ligand-protein interaction energies")19 parser.add_argument('files',nargs="+",help="the Gromacs xvg-files")20 parser.add_argument('-o','--out',help="the output file")21 parser.add_argument('-p','--pdb',help="the protein",default=[])22 parser.add_argument('-r','--repeats', help="repeat replacement", default=["r1_", "r2_", "r3_", "r4_", "r5_", "r6_", "r8_", "r9_", "r10_"])23 args = parser.parse_args()24residues = ["CU", "CL"]25for res in pdb.PDBFile(args.pdb).residues[:235] :26 residues.append("%s%d"%(res.resname.capitalize(),res.serial))27all_data = None28for ri, replacement in enumerate(args.repeats):29 r_data = []30 if ri == 0 :31 outname = args.out32 else:33 outname = args.out.replace(args.repeats[0], replacement)34 with open(outname, "w") as f :35 if ri == 0 :36 files = args.files37 else :38 files = [file.replace(args.repeats[0], replacement) for file in args.files]39 for file in files :40 data = parsing.parse2ndarray(file)41 (nrows, nitems) = data.shape42 for i in range(1, nitems, 2):43 ele_str, ele = _make_stats(data[:, i])44 vdw_str, vdw = _make_stats(data[:, i+1])45 tot_str, tot = _make_stats(data[:, i] + data[:, i+1])46 ele.extend(vdw)47 ele.extend(tot)48 r_data.append(ele)49 f.write("%s\t%s\t%s\t%s\n"%(residues[i-1], ele_str, vdw_str, tot_str))50 if ri == 0 :51 r_data = np.asarray(r_data)52 nrow, ncol = r_data.shape53 all_data = np.zeros([len(args.repeats), nrow, ncol])54 all_data[0, :, : ] = r_data55 else :56 all_data[ri, :, : ] = np.asarray(r_data)57with open(args.out.replace(args.repeats[0], "all_"), "w") as f :58 mean_data = all_data.mean(axis=0)59 for i in range(0, 7, 3):...
test_performance.py
Source: test_performance.py
...14 telegraf_server, telegraf_client = telegraf_server_client15 telegraf_client.sender._batch_size = batch_size16 rounds = 1017 loops = 99918 stats_session = custom_benchmark._make_stats(iterations=1)19 for _ in range(rounds):20 await _runner(telegraf_client, loops=loops, stats_session=stats_session)21 await asyncio.sleep(0.1) # flush buffers22@pytest.mark.parametrize('batch_size', [0, 50, 200, 500, 1000])23async def test_perf_multiple_workers(custom_benchmark, telegraf_server_client, batch_size):24 telegraf_server, telegraf_client = telegraf_server_client25 telegraf_client.sender._batch_size = batch_size26 rounds = 1027 workers = 1028 stats_session = custom_benchmark._make_stats(iterations=1)29 for round_num in range(rounds):30 tasks = [_runner(telegraf_client, loops=99, stats_session=stats_session) for _ in range(workers)]31 await asyncio.gather(*tasks)32 await asyncio.sleep(0.2) # flush buffers33async def _runner(telegraf_client, loops, stats_session):34 started_at = timer()35 for i in range(loops):36 telegraf_client.timing('perf.timer', 0.003, tags=['name:marlin', 'flow:custom'])37 await asyncio.sleep(0.0)...
Check out the latest blogs from LambdaTest on this topic:
Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
The holidays are just around the corner, and with Christmas and New Year celebrations coming up, everyone is busy preparing for the festivities! And during this busy time of year, LambdaTest also prepped something special for our beloved developers and testers – #LambdaTestYourBusiness
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!!