为了更好的理解性能场景,引入iteration的概念。Iteration,迭代。通过设置,可以指定虚拟用户在同一个Action中重复执行多次,每次重复称之为一个iteration。Iteration可以帮助我们模拟现实世界的重复场景。
Pacing,步调。可以通过设置两次迭代之间的间隔时间,来调整各个action之间的步调(或者称之为节奏)。从定义上来看,Pacing是和iteration绑定在一起的,可以认为是iteration pacing。
Pacing有三个选项: 1、As soon as the previous iteration ends(无时间间隔)即:pacing不生效 前一个迭代结束后,立即开始新的迭代; 2、After the previous iteration ends(with a fixed/randromdelay of x sec) 前一个迭代结束后,延时X秒(可为固定值,也可为某个区间的随机值) 3、At fixed/randrom intervals,every x sec 前一个迭代开始到新的迭代开始前,中间间隔X秒(可为固定值,也可为某个区间的随机值)
其与响应时间关系:
举例如下:
Action()
{
longt;
time(&t);
lr_output_message("当前中国区时间:%s",ctime(&t));
return0;
}
选项1运行结果:
Virtual User Script started at : 2015-04-21 15:06:35
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:06:35 2015
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:06:35 2015
Ending action Action.
Ending iteration 2.
Starting iteration 3.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:06:35 2015
Ending action Action.
Ending iteration 3.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
选项2运行结果:
Virtual User Script started at : 2015-04-21 15:18:56
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:18:56 2015
Ending action Action.
Ending iteration 1.
Waiting 1.0000 seconds for iteration pacing.
Starting iteration 2.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:18:57 2015
Ending action Action.
Ending iteration 2.
Waiting 1.0000 seconds for iteration pacing.
Starting iteration 3.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:18:58 2015
Ending action Action.
Ending iteration 3.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
选项3运行结果:
Virtual User Script started at : 2015-04-21 15:21:11
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:21:11 2015
Ending action Action.
Ending iteration 1.
Waiting 0.9710 seconds for iteration pacing.
Starting iteration 2.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:21:12 2015
Ending action Action.
Ending iteration 2.
Waiting 0.9600 seconds for iteration pacing.
Starting iteration 3.
Starting action Action.
Action.c(7): 当前中国区时间:Tue Apr 21 15:21:13 2015
Ending action Action.
Ending iteration 3.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.