loadrunner接口性能测试分享
来源:互联网 发布:mac mini性能怎么样 编辑:程序博客网 时间:2024/06/05 14:30
最近做了一次java脚本的lr性能测试
不过后来直接用eclipse进行了一次模拟,感觉也不错
先说lr
选择JavaVuser
之后 会生成脚本如下:
*/import lrapi.lr;public class Actions{ public int init() throws Throwable { return 0; }//end of init public int action() throws Throwable { return 0; }//end of action public int end() throws Throwable { return 0; }//end of end}
在你的脚本中增加
*/import lrapi.lr;public class Actions{ public int init() throws Throwable { return 0; }//end of init public int action() throws Throwable { lr.start_transaction("b2b"); //增加数据 统计//在这里增加你的代码即可//增加判断逻辑if(!(responseString ==null)&&responseString.contains("recharge failed")){ lr.end_transaction("b2b", lr.PASS); }else{ lr.end_transaction("b2b", lr.FAIL); } return 0; }//end of action public int end() throws Throwable { return 0; }//end of end}
在这里增加你的jar即可
根据tps公式,用eclipse模拟如下:
public class ThreadTest { public static int threadCount=20;//启动线程数量 public static int threadExcuteCount=1000000;//每个线程执行任务次数,没有数量的时候设置为999999999默认无穷大 public static int average; //每个任务执行的平均耗时 public static float tps; //瞬时tps public static int allhits=threadCount*threadExcuteCount; //总执行任务数量 public static void main(String[] args) { for (int i = 0; i <threadCount; i++) { Thread th= new Thread(new Runnable1()); th.setName("测试线程"+i); th.start(); } }} class Runnable1 implements Runnable{ public void run() { for (int i = 0; i < 1000; i++) { long startTime=System.currentTimeMillis();//记录开始时间// CbApplyPayShortcut_DEBITCARD test = new CbApplyPayShortcut_DEBITCARD();// test.main(null); cbPreAuthDirect test = new cbPreAuthDirect(); try { test.main(null); } catch (Exception e) { // TODO: handle exception } System.out.println(""); long endTime=System.currentTimeMillis();//记录结束时间 float excTime=(float)(endTime-startTime); ThreadTest.tps=(float)ThreadTest.threadCount*(1000/excTime); try { Thread.sleep(200000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }// System.out.println(Thread.currentThread().getName()+"||当前线程执行次数:"+i+"||耗时为:||"+excTime+"||TPS=||"+ThreadTest.tps+"||执行结果:"+test.flag); System.out.println("++++++++++++++++++++++++++++++++++++++++++"); } }}
阅读全文
0 0
- loadrunner接口性能测试分享
- LoadRunner测试接口性能
- LoadRunner接口性能测试示例
- LoadRunner接口性能测试示例
- webserivice接口loadrunner性能测试
- 图解LoadRunner实现SOAP接口性能测试
- 图解LoadRunner实现SOAP接口性能测试
- 性能测试分享---java vuser协议(2)---LoadRunner篇
- loadrunner如何测试sqlserver数据库性能思路分享
- 性能loadrunner--loadrunner测试工程
- LoadRunner中对接口进行性能测试的常用方法
- LoadRunner中对接口进行性能测试的常用方法
- 使用loadrunner编写dubbo接口的性能测试脚本
- loadrunner接口性能测试获取返回参数再传参脚本
- loadrunner使用JavaVuser协议测试API接口性能
- 使用loadrunner做webservices接口的性能测试
- Loadrunner Webservice接口性能测试脚本编写优化总结
- loadrunner接口测试
- git与github
- 26天学通前端开发(配资料)
- display
- 35个毁掉你代码的不良习惯!
- PID算法的理解及实现
- loadrunner接口性能测试分享
- 关于执行命令:sudo apt-get update后的“E: 无法解析或打开软件包的列表或是状态文件”问题解决
- JBoss和Tomcat部署方式的区别
- Mac与Linux SSH无密登陆(互信)
- 原来java的泛型是这样的
- 金蝶K3 PLM 系列版本破解授权注册
- 基于DragonBord410C的智能遥控
- 基础算法题(1)—— 题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的四位数?
- Java:重入锁ReentranLock详解、代码实战、与Synchronized对比