1

I need to send elapsed time in header of each request. To do this I use inline javaScript in HTTP Header Manager as following:

enter image description here

If there is any way to do the same with BeanShell instead of javaScript?

lyres
  • 115
  • 7

1 Answers1

1

I think since JMeter 3.1 you are supposed to be using JSR223 Test Elements and Groovy language for scripting so here is something similar for the __groovy() function:

${__groovy(((System.currentTimeMillis() - (vars.get('TESTSTART.MS') as long)) / 1000).round(1),)} 

More information: Apache Groovy - Why and How You Should Use It

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Just a small comment - to return seconds as an integer (as in my javascript example) - round(1) should be changed to round(0) or even just round(). – lyres Jun 15 '21 at 18:41