0

fellow QAs! Background - apache jmeter 4.0 is used in combination with ChromeWebDriver for loadtesting a jsf web application. In jmeter numerous JSR223\Groovy samplers are used to control locally started chromedriver by executing org.openqa.selenium methods. My current task is to implement pacing. I took this tutorial - https://www.blazemeter.com/blog/how-to-easily-implement-pacing-jmeter as a basis, and it looks to work ok at first, but there's one problem, kind of a strange one, that I can't defeat. When I put several jsr223 samplers under a transaction controller, and place another JSR right after it, with this code:

//Sets the pacing length based on the last requests response time. 4500 is the time in ms
Long pacing = 4500 - prev.getTime();

//If the response time is less than 4500 ms, set the delay value to myDelay
if ( pacing > 0 ) 
{ 
    //iPacing is equal to the int value of pacing if pacing is not equal to null, otherwise iPacing is null
    Integer iPacing = pacing != null ? pacing.intValue() : null; 
    log.info(String.valueOf(iPacing));
    vars.put("myDelay", String.valueOf(iPacing)); 
    return iPacing; 
}
//The response time is greater than or equal to 4500 ms, set myDelay to 0
else 
{ 
    vars.put("myDelay", "0");
    return 0; 
}

the prev.getTime() method returns execution time only for the last sampler under a transaction controller, not the total time! I tried setting and unsetting "Generate parent sample" checkbox - result is still the same. Here is how the scenario looks: enter image description here Any help will be greatly apreciated!

1 Answer 1

0

Transaction Controller is a different beast, you can fetch total transaction controller execution time as prev.getParent().getTime()

Just in case if you need individual Transaction Controller's children you can go for prev.getParent().getSubResults() function:

prev.getParent().getSubResults().each {result ->
    log.info('Sampler: ' + result.getSampleLabel() + ' Elapsed time: ' + result.getTime() )
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.