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.