脚本有点长,但不要被吓到了,重要的几句我已经加了注释。你只用关注那几行就行了。
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; //定义变量 ....... if (trans_time) { lr_end_transaction("注册",LR_AUTO); //事务结束 |
感谢上面这段代码很好帮助我们理解思考时间。
备注:添加思考时间可以更真实的模拟用户行为,但它同时降低了用户并发。也就是说思考时间越长,对服务器的压力会越小。
相关链接: