On 25/10/06, Bennett McElwee <[EMAIL PROTECTED]> wrote:
I have a BeanShell sampler that has an initialisation method that reads
a file into a data structure. Since a separate BeanShell interpreter is
created for each thread, this work is being repeated for every thread.
Two problems here:

- Wasted work -- the file only needs to be read once, and then the data
structure can be shared across threads.

- Synchronization -- If two threads try to read the file at the same
time, they might step on each other (since I use JMeter's FileServer).

I plan to do two things:

- Synchronise the routine that reads the file into the data structure so
it only happens once.

- Put the data structure into a JMeter variable so all threads can share
it.

And I have a couple of questions:

1. What should I synchronize on? I really want to synchronise on the
FileEntry object created by the FileServer, but I can't get hold of it.
I could synchronise on the FileServer itself but that's overkill. The
problem is that there's no way in BeanShell to create an appropriately
global, cross-thread object to synchronise on.


You might be able to use one of the variables exposed to the BeanShell
script to walk back up the hierarchy to find something suitable.

2. Are JMeter variables shared across threads?

No. Otherwise it would not be possible to have different values of
(say) the username for different threads.

Properties are global, but I can't see how to use those for synchronisation.

I would appreciate your thoughts.


You might find it worthwhile creating your own version of the File Server.

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to