0
votes

I have a threadgroup with JSR223 pre-processor that loops through unique IDs of the objects and makes a request for that object resource. I am attempting to address all the objects, which could be in millions. To overcome maximum thread limitations, each thread addresses specific set of objects and loops through this set. The entire threadgroup runs for a specific time period. This is the pre-processor groovy script.

// get unique object Id for the thread request
int numThreads = Integer.parseInt(args[0]);
int totalObjects = Integer.parseInt(args[1]);
int objectsPerThread = totalObjects/numThreads;
int initialObjectsCount = (ctx.getThreadNum()) * objectsPerThread;
int objectId = initialObjectsCount + (ctx.getVariables().getIteration()) % objectsPerThread;

vars.put("uniqueId", Integer.toString(objectId));

All is well when this script is pasted right in the GUI. The JMeter client is able to saturate the server easily. I would like to use this script in multiple places and extracted this into a file to be shared across JMX files. When I do that and specify the file name for the script in JSR223, JMeter client is unable to perform at the same efficiency as when this script was pasted in the GUI. The Cache compiled script if available option is checked in both cases.

  • Is this expected?
  • Is there a better way to share the scripts, such as, using test fragments, assuming pre-processors can be used as test fragments.
1

1 Answers

1
votes

This is kind of expected as file IO is slower than memory operation.

If this is critical you can use a Test Fragment and a Module Controller to avoid code duplication.

Just be aware that a PreProcessor is being executed only with conjunction with the Sampler so you will have to switch to the JSR223 Sampler

If you don't want to see the JSR223 Sampler in your test results just add the next line somewhere in your script:

SampleResult.setIgnore()

and it will suppress the output so the sampler won't be caught by Listeners and you won't see it in the .jtl results file