Loadrunner使用小技巧

     一、网络带宽问题

     对web进行压力测试时,一般百兆网络是不够的,当网络带宽不够的时候server端没有足够压力。用loadrunner所在的windows的性能管理器看一下网络利用率就知道了。html

     二、Vuser脚本的检查

     Loadrunner提供了方便的脚本录制功能,但因为录制时可能出现的操做错误,vuser访问一些不存在的资源。去除某些与压力测试无关的东西。不然可能会出现Loadrunner测试结果有误或压力上不去的状况web

    三、Runtime setting

    在建立Loadrunner scenario时,每台机器的vuser的runtime settings都应该分别设置并检查,不能只对第一个vuser的runtime settings进行设置。一般你会关掉think time,以便能用较少的机器达到较大的压力。另外,若是返回页面里包含了一些访问其余资源的连接好比图片服务器,这时应关掉 download non-html resources。windows

    四、没有检查返回页面

    当server端出错时应用程序有可能返回错误信息,但对HTTP来说还是成功的响应,返回码为200 OK. 这样在Loadrunner就被记为成功的transaction。因而,server端出错越多,Loadrunner测出的性能越好。解决办法:开启并检查应用的错误日志;或者启用Loadrunner的返回内容检查功能。bash

    五、小心Loadrunner所在机器的磁盘空间

     缺省状况下Loadrunner会把运行结果的详细信息放在C盘的Documment and Settings的用户目录下,当大压力长时间运行或有大量出错时,Loadrunner会生成大量的数据到该目录下。当磁盘空间满了后,机器的响应将变得很慢。服务器

     六、命令行打开LoadRunner

   在多个场景须要运行的时候,能够经过批处理循环运行场景,保存结果到指定文件夹:网络

   bat内容:性能

set LR_HOME=C:\Program Files\Mercury\LoadRunner
for /L %%iScenario   in (1,1,10) do "%LR_HOME%\bin\Wlrun.exe" -Run -TestPath "%LR_HOME%\scenario\memory_leak_crash.lrs" -ResultName C:\LR_Result\result%%iScenario

  因为lr的http 200的经典错误,因此须要加入验证点,若是加入了验证点,就使事务响应时间大于实际的响应时间,如何解决呢,利用lr_wasted_time解决,代码以下:测试

double time_elapsed, duration, waste;
   merc_timer_handle_t timer;
   lr_start_transaction("sampleTrans");

   web_url("index.htm",
           "URL=http://localhost/index.htm",
           "TargetFrame=",
           "Resource=0",
           "RecContentType=text/html",
           "Referer=",
           "Snapshot=t1.inf",
           "Mode=HTML",
           LAST);

   timer = lr_start_timer();

   // Do some checks the duration of which is not to be included in the transaction.
   web_image_check("ImgCheck1",
           "src=index_files/image002.jpg",
           LAST);

   web_image_check("ImgCheck2",
           "src=index_files/planets.gif",
           LAST);

   // How long did the tests take in seconds.
   time_elapsed = lr_end_timer(timer);

   // Convert to millisecond.s
   waste = time_elapsed * 1000;

   // Remove the time the checks took from the transaction.
   lr_wasted_time(waste);
   lr_end_transaction("sampleTrans", LR_AUTO);
相关文章
相关标签/搜索