Pages

Monday 30 January 2017

JMeter - Timer - "JSR223 Timer"

JSR223 Timer is a scripting-based timer. JSR stands for Java Specification Requests. As same as BeanShell timer which we discussed earlier; you need to implement the thread delay logic by yourself using one of the supported scripting languages like Groovy, BeanShell, java, javascript, jexl etc. Usually, it is helpful when you need to define think times based on some unique algorithm which is not currently provided by JMeter. You can create your own implementation of the algorithm using the JSR223 timer. The simplest groovy code could be written in the JSR timer is "return <delay time>" where the delay time is in milliseconds.
Example: return 5000

How to add "JSR223 Timer" element?
You can follow the below steps:
1. Select "Test Plan" or "Thread Group" or "Controller" or "Sampler" node where you want to add the timer
2. Right-click on the node
3. Mouse hovers "Add"
4. Mouse hovers "Timers"
5. Click "JSR223 Timer"

How to remove "JSR223 Timer" element?
You can follow the below steps:
1. Select "JSR223 Timer" node
2. Right click on "JSR223 Timer" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard

4. Click "Yes"    

What are the attributes of "JSR223 Timer" element?

"JSR Timer" has following attributes:
  • Name: To provide the name of the timer
  • Comments: To provide arbitrary comments (if any)
  • Language: To choose scripting language. 
  • Parameters: Parameters to pass to the script. This is an optional attribute.  
  • Script file: A file containing the script to run. The return value is used as the number of milliseconds to wait.
  • Script compilation caching: Unique String across Test Plan that JMeter will use to cache the result of script compilation if the language used supports Compilable interface (Groovy is one of these, Java, BeanShell and javascript are not)
  • Script: The manual script which contains the logic to generate think (delay) time. The return value is used as the number of milliseconds to wait.
Recommendation: It is recommended to use JSR223 test elements and Groovy as a language for any scripting. Groovy scripting is as fast as Java while BeanShell and JavaScript need to be interpreted, which causes some performance overhead. 

Next Topic:
Apache JMeter - "Poisson Random Timer" Element

Previous Topic:
Apache JMeter - "Gaussian Random Timer" Element

Related Topics:

No comments:

Post a Comment