0
votes

I have a HTTP request , which will start at time , this value am storing in string variable beforetime String beforetime=${​​​​​__time(,)}​​​​​; Before Time ----> 1611822129009 This transaction will be saved in database with modified_date as 2021-01-28 13:08:30.923 I am extracting time from modified_date as below String CurrentTime1=${__groovy(${__groovy(Date.parse('yyyy-MM-dd hh:mm:ss.SSS','${Modified_date_1}').getTime(),)},)} ;

Now current time is --->1611822133322 the difference between this two is difference ---->4313

  1. the difference between this two time is not actual time(it is calculated by converting to string), how to get the actual difference ? 2)I need to populate the difference time for each HTTP request dynamically in Jmeter report , can you help me to do this ?
2

2 Answers

0
votes

Given you have:

  • JMeter Variable ${before_time) with the value of 1611822129009
  • JMeter Variable ${modified_date) with the value of 1611822133322

enter image description here

You can calculate the difference and store it into another JMeter Variable using any suitable JSR223 Test Element and the following Groovy code:

def before = vars.get('before_time') as long
def after = vars.get('modified_date') as long

log.info('Before: ' + before)
log.info('After: ' + after)

def difference = after - before

log.info('Difference: ' + difference)

vars.put('difference', difference as String)

The above code subtracts before_time from the modified_date and stores the result into difference JMeter Variable

enter image description here

Now you can add the next line to user.properties file (lives in "bin" folder of your JMeter installation)

sample_variables=difference

and next time you run JMeter in command-line non-GUI mode the .jtl results file will contain the ${difference} variable value for each sampler. You can even plot the value as a custom chart in the HTML Reporting Dashboard

More information:

0
votes

I used a below command to run in non-GUI mode
jmeter -n -t C:\Users\systemname\Desktop\apache-jmeter\apache-jmeter-5.1.1\apache-jmeter-5.1.1\bin\TestScript\SG_Exp2.0_SVT-PerfTesting.jmx -l C:\Users\systemname\Desktop\apache-jmeter\apache-jmeter-5.1.1\apache-jmeter-5.1.1\bin\TestScript\Testresults\results.csv
But i got a below error can you suggest me how resolve this ? Error in NonGUIDriver org.apache.jorphan.util.JMeterStopTestException: ModuleController:Module Controller has no selected Controller (did you rename some element in the path to target controller?), test was shutdown as a consequence