JMeter save load time into a variable

1.6k Views Asked by At

I cannot seem to save the load/response/sample time into a variable using RegEx. Sampler Results page

Is there a way to access the results from the Sampler Results page?

1

There are 1 best solutions below

0
Rohit On

You cannot extract Response time using regular expressions because regular expression extractor is limited to the following options and response time is calculated by JMeter

enter image description here

However you can use JMeter's SampleResult api to get load time. The api has methods for endtime and starttime of a sample, using this methods you can calculate load time and then store it in JMeter variable.

Loadtime= endtime-starttime

Add a Beanshell post processor to your sampler and add the following code to the post processor

long starttime=prev.getStartTime();

long endtime=prev.getEndTime();

int loadtime=endtime-starttime;

vars.put("Load time",Integer.toString(loadtime));

You can use ${Load time} to get load time of that particular sample enter image description here

More info:

Regular expression extractors

Beanshell