How to measure size of response data of multiple http samplers in JMeter. I need to find the individual size of all http sampler during the load, not for overall.
I am using Beanshell sampler but it is giving overall size not individual for each sampler.
import java.util.io.*;
import java.lang.io.*;
test = prev.getResponseDataAsString().length();
text = ctx.getCurrentSampler().getName();
log.info("Sampler Name: " +text+ ": Size: " +test);
if(text.equalsIgnoreCase("Test Sampler"))
{
props.put("totalsize",Integer.parseInt("0"));
}
else
{
props.put("totalsize", (props.get("totalsize")!=null?props.get("totalsize"):0) + test);
}
log.info("totalsize is = "+props.get("totalsize"));
I am using Beanshell sampler but it is giving overall size not individual for each sampler.
I need total individual response size for each sampler during my load test.
>Solution :
-
First of all I don’t understand fully what your code is doing. You’re using
propsshorthand for storing the data and the properties are global for the whole JVM so if you run your test with > 1 user the next thread will overwrite the value set by the previous thread. Maybe you should usevarsinstead which is for JMeterVariables which are thread-local? -
I believe JMeter saves it into its .jtl results file by default, take a look at
bytescolumn which contains response size for each individual sampler. -
Also be aware that starting from JMeter 3.1 it’s recommended to use JSR223 Test Elements and Groovy language for scripting mainly for performance reasons so consider migrating. More information: Beanshell vs. JSR223 vs. Java For JMeter: Complete Showdown
