JMeter – BeanShell Timer

JMeter BeanShell Timer is a scripting-based timer. It means that you have to implement the thread delay logic by yourself using one of the supported scripting languages. Usually, it is helpful when you need to define think time-based on some unique algorithm which is not currently provided by JMeter. You can implement your own algorithm using a BeanShell timer.

How to add ‘BeanShell Timer’ in the JMeter script?

Follow the below steps to add BeanShell Timer:

  1. Select the appropriate node where you want to add the time
    1. Test Plan
    2. Thread Group
    3. Controller
    4. Sampler
  2. Right-click on the node
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘Timers’
  5. Click ‘BeanShell Timer’
JMeter - BeanShell Timer
Figure 01: JMeter – BeanShell Timer

What are the input fields of ‘BeanShell Timer’?

  1. Name: To provide the name of the timer
  2. Comments: To provide arbitrary comments (if any)
  3. Reset bsh.Interpreter before each call: The interpreter will be recreated by selecting the value of this option as ‘Yes’. 
  4. Parameters: Parameters to pass to the BeanShell script. This is an optional attribute.  
  5. Script file: A file containing the BeanShell script to run. The return value is used as the number of milliseconds to wait.
  6. Script: The BeanShell script contains the logic to generate think time. The return value is used as the number of milliseconds to wait.

Recommendation: It is recommended to use the JSR223 timer and Groovy as a language. Groovy scripting is as fast as Java while BeanShell and JavaScript need to be interpreted, which causes some performance overhead. 

You may be interested:

Leave a Comment