qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

jmeter之定时器

18.6.6 BeanShell Timer

The BeanShell Timer can be used to generate a delay.

For full details on using BeanShell, please see the BeanShell website.

The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.

Control Panel

Parameters

            
AttributeDescriptionRequired
NameDescriptive name for this element that is shown in the tree. The name is stored in the script variable LabelNo
Reset bsh.Interpreter before each callIf this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see Best Practices - BeanShell scripting .Yes
ParametersParameters to pass to the BeanShell script. The parameters are stored in the following variables:
  • Parameters - string containing the parameters as a single variable
  • bsh.args - String array containing parameters, split on white-space
No
Script fileA file containing the BeanShell script to run. The file name is stored in the script variable FileName The return value is used as the number of milliseconds to wait.No
ScriptThe BeanShell script. The return value is used as the number of milliseconds to wait.Yes (unless script file is provided)

 

Before invoking the script, some variables are set up in the BeanShell interpreter:

  • log - (Logger) - can be used to write to the log file
  • ctx - ( JMeterContext ) - gives access to the context
  • vars - ( JMeterVariables ) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());
  • props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
  • prev - ( SampleResult ) - gives access to the previous SampleResult (if any)

For details of all the methods available on each of the above variables, please check the Javadoc

If the property beanshell.timer.init is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.


18.6.7 BSF Timer

The BSF Timer can be used to generate a delay using a BSF scripting language.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this element that is shown in the tree.No
ScriptLanguageThe scripting language to be used.Yes
ParametersParameters to pass to the script. The parameters are stored in the following variables:
  • Parameters - string containing the parameters as a single variable
  • args - String array containing parameters, split on white-space
No
Script fileA file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System property The return value is converted to a long integer and used as the number of milliseconds to wait.No
ScriptThe script. The return value is used as the number of milliseconds to wait.Yes (unless script file is provided)

 

Before invoking the script, some variables are set up in the script interpreter:

  • log - (Logger) - can be used to write to the log file
  • ctx - ( JMeterContext ) - gives access to the context
  • vars - ( JMeterVariables ) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());
  • props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
  • sampler - the current Sampler
  • Label - the name of the Timer
  • Filename - the file name (if any)
  • OUT - System.out

For details of all the methods available on each of the above variables, please check the Javadoc


18.6.4 Constant Throughput Timer

This timer introduces variable pauses, calculated to keep the total throughput (in terms of samples per minute) as close as possible to a give figure. Of course the throughput will be lower if the server is not capable of handling it, or if other timers or time-consuming test elements prevent it.

N.B. although the Timer is called the Constant Throughput timer, the throughput value does not need to be constant. It can be defined in terms of a variable or function call, and the value can be changed during a test. The value can be changed in various ways:

  • using a counter variable
  • using a JavaScript or BeanShell function to provide a changing value
  • using the remote BeanShell server to change a JMeter property

See Best Practices for further details. Note that the throughput value should not be changed too often during a test - it will take a while for the new value to take effect.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the tree.No
Target ThroughputThroughput we want the timer to try to generate.Yes
Calculate Throughput based on
  • this thread only - each thread will try to maintain the target throughput. The overall throughput will be proportional to the number of active threads.
  • all active threads in current thread group - the target throughput is divided amongst all the active threads in the group. Each thread will delay as needed, based on when it last ran.
  • all active threads - the target throughput is divided amongst all the active threads in all Thread Groups. Each thread will delay as needed, based on when it last ran. In this case, each other Thread Group will need a Constant Throughput timer with the same settings.
  • all active threads in current thread group (shared) - as above, but each thread is delayed based on when any thread in the group last ran.
  • all active threads (shared) - as above; each thread is delayed based on when any thread last ran.
Yes

 



18.6.9 Poisson Random Timer

This timer pauses each thread request for a random amount of time, with most of the time intervals ocurring near a particular value. The total delay is the sum of the Poisson distributed value, and the offset value.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the treeNo
LambdaLambda value in milliseconds.Yes
Constant Delay OffsetNumber of milliseconds to pause in addition to the random delay.Yes

 



^

18.6.5 Synchronizing Timer

The purpose of the SyncTimer is to block threads until X number of threads have been blocked, and then they are all released at once. A SyncTimer can thus create large instant loads at various points of the test plan.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the tree.No
Number of Simultaneous Users to Group byNumber of threads to release at once. Setting it to 0 is equivalent to setting it to Number of threads in Thread Group.Yes

 

18.6.3 Uniform Random Timer

This timer pauses each thread request for a random amount of time, with each time interval having the same probability of occurring. The total delay is the sum of the random value and the offset value.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the tree.No
Random Delay MaximumMaxium random number of milliseconds to pause.Yes
Constant Delay OffsetNumber of milliseconds to pause in addition to the random delay.Yes

18.6.1 Constant Timer

If you want to have each thread pause for the same amount of time between requests, use this timer.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the tree.No
Thread DelayNumber of milliseconds to pause.Yes



18.6.2 Gaussian Random Timer

This timer pauses each thread request for a random amount of time, with most of the time intervals ocurring near a particular value. The total delay is the sum of the Gaussian distributed value (with mean 0.0 and standard deviation 1.0) times the deviation value you specify, and the offset value. Another way to explain it, in Gaussian Random Timer, the variation around constant offset has a gaussian curve distribution.

Control Panel

Parameters

AttributeDescriptionRequired
NameDescriptive name for this timer that is shown in the treeNo
DeviationDeviation in milliseconds.Yes
Constant Delay OffsetNumber of milliseconds to pause in addition to the random delay.Yes

posted on 2014-03-03 11:55 顺其自然EVO 阅读(1683) 评论(0)  编辑  收藏 所属分类: jmeter


只有注册用户登录后才能发表评论。


网站导航:
 
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜