0
votes

I have csv file with 10,000 entries. for each iteration, i want to use few 100's of entries. i have loaded into a java list in JSR223 sampler under only once controller. so that, i can load once and use this master list to retrieve chunk of records every time in other JSR223 samplers. i am not able to access variables "totalrows", "lines" defined in one JSR223 sampler from another JSR223 sampler in different thread group. Any other way apart from using vars.get() to get global scope for variables defined to JSR223 sampler

import org.apache.commons.io.FileUtils;   
List lines = FileUtils.readLines(new File("skuinfo.csv")); 

int totalrows = lines.size();

1
Each script is self-contained. You cannot share parts of script with other scripts. Even second execution of the same script is going to run again, and will recreate the list. So it will read everything on each execution... What are you trying to achieve though? Why not read chunks of CSV using normal way? - Kiril S.

1 Answers

0
votes

Variables are thread related, to be able to share you need to use properties (props in jsr223 test elements).

But I would advise you not to use this method as it will impact performances of JMeter particularly if your code is not correctly developed.

You also need to handle synchronization as objects will be shared among threads.

So it’s better to use built-in mechanism of JMete, ie CSV DataSet and prepare data before test.