1

I'm trying the get the response time for the complete test case (All transactions) in JMeter. I'll be using it for calculating pacing using JSR223 Timer

I am able to get time for single sample using prev.getTime() but when I use prev.getParent().getTime(), I don't see anything in logs and script doesn't halt for pacing.

I have also tried placing the timer at a different level (Scope of thread group) still nothing. Where I am going wrong here?

Thanks, Sachin

Ori Marko
  • 56,308
  • 23
  • 131
  • 233

1 Answers1

0

prev.getParent() function is applicable for subresults for example when the Sampler is a child of a Transaction Controller.

If you have a single Sampler somewhere in Thread Group it will not have any parent hence your function will fail with the NPE.

You can work it around by introducing checking this getParent() for null like:

def time = 0
if (prev.getParent() != null) {
    time = prev.getParent().getTime()
} 
else {
    time = prev.getTime()
}

Check out How to Easily Implement Pacing in JMeter article for more comprehensive information if needed.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • @Dmitri T - Thanks for your help. I figured out "Generate Parent Sample" was not checked so i couldnt get the transaction time. But to get the iteration time (All transaction combined) in a variable is not working for me. prev.getParent() updates time for each transaction and hence couldn't fetch it. – Sachin Hulawale Nov 22 '19 at 13:14