Finalizing a Script
We'll see in this section some nice tips to save time during scripting and to not end up with too-complex scripts due to a lack of knowledge of JMeter features.
Changing the Name of a Transaction According to a Parameter
In some cases, it is useful to be able to change the name of a transaction during runtime and not during scripting, such as when:
- Comparing the performance of the same query with different parameters
- Numerating the request to validate that none are lost
- Changing the name according to the answer
As often, several solutions are available:
- Use a value from a CSV file field using CSV Data Set Config.
- Use a JMeter function such as __counter, __RandomDate, or __Random.
- Use JSR223 Listener and the prev.setSampleLabel function; for example, to change the name to VerySlow for responses that take more than 400ms:
if (prev.getTime() > 400) {
prev.setSampleLabel("VerySlow")
}