loadrunner接口性能测试分享
2017-10-16 16:24
459 查看
最近做了一次java脚本的lr性能测试
不过后来直接用eclipse进行了一次模拟,感觉也不错
先说lr
选择JavaVuser
之后 会生成脚本如下:
在你的脚本中增加
在这里增加你的jar即可
根据tps公式,用eclipse模拟如下:
不过后来直接用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("+++++++++++++++++++++++++++++++++ 4000 +++++++++"); } } }
相关文章推荐
- 使用loadrunner做webservices接口的性能测试
- LoadRunner测试接口性能
- LoadRunner中对接口进行性能测试的常用方法
- Loadrunner调用Webservice接口进行性能测试时的方法及优化总结
- 老李分享:Eclipse中开发性能测试loadrunner脚本
- loadrunner如何测试sqlserver数据库性能思路分享
- LoadRunner接口性能测试示例
- Loadrunner Webservice接口性能测试脚本编写优化总结
- loadrunner测试mysql中某个sql语句或存储过程的性能分享
- LoadRunner安装包(性能测试工具分享)
- LoadRunner接口性能测试示例
- 使用loadrunner编写dubbo接口的性能测试脚本
- Loadrunner 调用 Webservice 接口 进行 性能测试 时的方法及优化总结
- 老李分享:Eclipse中开发性能测试loadrunner脚本
- 老李分享:性能测试你不应该只知道loadrunner(1)
- loadrunner使用JavaVuser协议测试API接口性能
- Loadrunner Http接口Get/Post方法性能测试脚本解析
- 老李分享:性能测试你不应该只知道loadrunner(1)
- loadrunner接口性能测试获取返回参数再传参脚本
- loadrunner另类玩法之接口功能测试-测试帮日记线上分享会