2026/3/15 12:33:45
网站建设
项目流程
广德网站建设,网站建设销售专业术语,行业资讯网站有哪些,怎样重新安装电脑wordpress用户访问某个网站或软件#xff0c;一般不会不停地做个各种操作#xff0c;例如一次查询#xff0c;用户需要时间查看查询的结果是否是自己想要的。例如一次订单提交#xff0c;用户需要时间核对自己填写的信息是否正确等。
也就是说用户在做某些操作时#xff0c;是会有…用户访问某个网站或软件一般不会不停地做个各种操作例如一次查询用户需要时间查看查询的结果是否是自己想要的。例如一次订单提交用户需要时间核对自己填写的信息是否正确等。也就是说用户在做某些操作时是会有停留时间的我把这个时间叫思考时间。但利用代码去执行的时候是没有时间的当然脚本运行本身是需要时间的但比起人的思考时间要小很多。这也是我们为什么要用软件来代替人的某些工作。但有时候我们在做性能测试时为了更真实的模拟用户的操作需要给代码加入思考时间。来看看在loadrunner是如何设置思考时间的。打开loadrunner 的Virtual User Generator菜单栏Vuser —Run-Time settings…,切换到Thark Time选项好吧为了更好的理解这个界面上设置现在我们通过一个脚本来分析。Action() { double trans_time; //定义变量 web_url(www.baidu.com, URLhttp://www.baidu.com/, Resource0, RecContentTypetext/html, Referer, Snapshott1.inf, ModeHTML, LAST); web_url(i-1.0.0.png, URLhttp://s1.bdstatic.com/r/www/img/i-1.0.0.png, Resource1, RecContentTypeimage/png, Refererhttp://www.baidu.com/, Snapshott2.inf, LAST); web_url(favicon.ico, URLhttp://www.baidu.com/favicon.ico, Resource1, RecContentTypeimage/x-icon, Referer, Snapshott3.inf, LAST); web_url(su, URLhttp://suggestion.baidu.com/su?wdcbwindow.bdsug.sugPreRequestsid1466t1362316450913, Resource1, RecContentTypebaiduapp/json, Refererhttp://www.baidu.com/, Snapshott4.inf, LAST); lr_start_transaction(注册); //添加事务 lr_think_time(20); //设置思考时间 web_url(v.gif, URLhttp://nsclick.baidu.com/v.gif?pid201pjwwwrsv_sid1466fmbehstabtj_regunpathhttp%3A%2F%2Fwww.baidu.com%2Ft1362316485456, Resource1, Refererhttp://www.baidu.com/, LAST); web_url(favicon.ico_2, URLhttps://passport.baidu.com/favicon.ico, Resource1, RecContentTypeapplication/octet-stream, Referer, Snapshott5.inf, LAST); web_link(注册, Text注册, Snapshott6.inf, LAST); web_custom_request(urs.asmx, URLhttps://urs.microsoft.com/urs.asmx?MSURS-Client-KeyWI0pAZHPdb%2b3UDOD0AtzxA%3d%3dMSURS-Patented-LockS1IpDfNCCC4%3d, MethodPOST, Resource0, RecContentTypetext/xml, Referer, Snapshott7.inf, ModeHTML, EncTypetext/xml; charsetutf-8, BodyRepLookup v\3\GED8654D5-B9F0-4DD9-B3E8-F8F560086FDF/GOF03F2D77-79E1-4DEC-BBF8-81A5C0790160/OD9.0.8110.0/DC9.00.8112.16421/COS6.1.7601.1.0/OSI9.0.8112.16421/ILzh-CN/LRRqURLaHR0cHM6Ly9wYXNzcG9ydC5iYWlkdS5jb20vdjIvP3JlZyZyZWdUeXBlPTEmdHBsPW1uJnU9aHR0cCUzQSUyRiUyRnd3dy5iYWlkdS5jb20lMkY/URLOPRE/OTTOP/THIP220.181.111.48/HIP/Rq/R/RepLookup, EXTRARES, Urlhttps://passport.baidu.com/img/topbarnav_bg.png, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, Urlhttps://passport.baidu.com/passApi/js/reg_6e270622.js, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, Urlhttps://passport.baidu.com/passApi/img/small_blank_9dbbfbb1.gif, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, LAST); web_url(api, URLhttps://passport.baidu.com/v2/api/?getapitplmnapiverv3tt1362316491971classregcallbackbd__cbs__c93h6w, Resource0, RecContentTypetext/html, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, Snapshott8.inf, ModeHTML, EXTRARES, Url/img/v.gif?type1regTypemail, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, LAST); web_url(api_2, URLhttps://passport.baidu.com/v2/api/?getapitplmnapiverv3tt1362316491978classregPhonecallbackbd__cbs__xs2rv5, Resource0, RecContentTypetext/html, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, Snapshott9.inf, ModeHTML, EXTRARES, Url/cgi-bin/genimage?001362316472015690A3686612594D3D2C14ABF30D0B432CF4462DF3A4B5A8E5E7B7EE094DCAB428311C96E23B35A3CB73A67533699084E25A27CF6C9745497B5C5435611E0593A615CC284B27D70CA5FFB5F771E5D7DC9EE266F6FD61A2D88FEC7B7BA20EFF5DE2CD301E011E634D5063BDDCD35A47C1EB7B5EF365B347DD5800C612B744FAEF845540239F1036CC800902957BD17F36F6547B71C198C154162F8F71077B935E6B, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, Url/img/bd-split.gif, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, Url/img/reg_tip_header_t.gif, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, Url/img/reg_tip_bg_bottom.gif, Refererhttps://passport.baidu.com/v2/?regregType1tplmnuhttp%3A%2F%2Fwww.baidu.com%2F, ENDITEM, LAST); trans_timelr_get_transaction_wasted_time(注册); //获得消耗时间 if (trans_time) { lr_output_message(The duration up to the submit is %f seconds,trans_time); //打印输出消耗实时间 }else{ lr_output_message(the duration cannot be determined. ); } lr_end_transaction(注册,LR_AUTO); //事务结束 return 0; }脚本有点长但不要被吓到了重要的几句我已经加了注释。你只用关注那几行就行了。lgnore think time :忽视思考时间也就说勾选这一项的时候 你脚本中加入的lr_think_time 函数设置是无效的。选中这一项运行上面的脚本。Action.c(62): The duration up to the submit is 0.032043 seconds Action.c(67): Notify: Transaction 注册 ended with Pass status (Duration: 12.4113 Wasted Time: 0.0320).虽然我在脚本中加入了lr_think_time(20); 这条语句显现没起到任何作用。Replay think time回放思考时间来看第一个选项As recorded 取决于记录选种这一项再来运行上面的脚本。Action.c(111): The duration up to the submit is 0.034508 seconds Action.c(116): Notify: Transaction 注册 ended with Pass status (Duration: 50.4453 Think Time: 20.0000 Wasted Time: 0.0345). Ending action Action.运行结果中多了一个 Think Time: 20.0000 这说明我们脚本中的lr_think_time(20); 起到了作用选中这一项后我们可以在脚本中任意的添加思考时间。Multiply recorded think time by: 录制思考时间乘以使用录制思考时间的倍数。其实在我们脚本录制的过程中根据我们的操作脚本中就可以生成相应的思考时间。这个参数是根据脚本中的思考时间进行调整的。例如脚本是20秒输入2那么在脚本实际运行时思考时间将为40秒输入0.5 脚本在运行时的思考时间为10秒。下面选中此项输入0.5再来查看脚本运行结果Action.c(111): The duration up to the submit is 0.036610 seconds Action.c(116): Notify: Transaction 注册 ended with Pass status (Duration: 131.2022 Think Time: 9.9998 Wasted Time: 0.0366).注将原谅脚本会有0.0002秒的误差。Use random percentage of recorded think time : 使用录制思考时间的百分比。通过指定思考的时间的范围可以设置思考时间值的范围。假如思考时间为20秒这里设置的范围为50% 到100% 那么脚本运行时候将随即的在这个范围10秒到20秒之间内取值。下面再来查看脚本运行时间Action.c(111): The duration up to the submit is 0.036191 seconds Action.c(116): Notify: Transaction 注册 ended with Pass status (Duration: 40.8002 Think Time: 15.0050 Wasted Time: 0.0362).这一次Think Time: 为15.0050 是在10到20秒的范围之内你再次运行会发现这个时间不一样但不会超出设定的范围。Limit think time to: 限制思考时间的最大值。假如脚本设置的思考时间为20秒选中这一项并设置为10秒。那么脚本在运行时思考时间不会超过10秒。也就是说这设置同样也制约前面几个选项。这个你可以自行设置验证。感谢double trans_time; //定义变量 ...... lr_start_transaction(注册); //添加事物 lr_think_time(8); //思考时间 ....... trans_timelr_get_transaction_wasted_time(注册); //获得消耗时间 if (trans_time) { lr_output_message(The duration up to the submit is %f seconds,trans_time); //打印输出消耗实时间 }else{ lr_output_message(the duration cannot be determined. ); } lr_end_transaction(注册,LR_AUTO); //事务结束..........感谢上面这段代码很好帮助我们理解思考时间。备注添加思考时间可以更真实的模拟用户行为但它同时降低了用户并发。也就是说思考时间越长对服务器的压力会越小。最后下方这份完整的软件测试视频教程已经整理上传完成需要的朋友们可以自行领取【保证100%免费】软件测试面试文档我们学习必然是为了找到高薪的工作下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料并且有字节大佬给出了权威的解答刷完这一套面试资料相信大家都能找到满意的工作。