jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From E S <>
Subject Set sampler start/end time directly
Date Tue, 28 Jun 2011 22:18:53 GMT
I have a custom sampler I wrote that spins off a number of threads to do the
actual requests, the results of which are added as sub results. So if your
test plan ran 5 users and each user made 10 requests from their virtual
browser, you'd have 5 results with 10 sub results under each one. The
problem I am having is setting the parent sampler start and end times
properly. Currently, I am starting the parent sampler before any of the
sub-threads start and ending it when all of the sub-threads have finished.
However, I'm getting times that are way too high in the parent sampler. My
guess is that it has to do with thread scheduling. For example, maybe there
are just so many threads running that it can't get to each one quick enough
to set the timer off at a reasonable time after the last request finished.

An easy way to solve this would be to loop through the sub results and get
the earliest start time and latest end time and set the parent result's
start and end time equal to those. Unfortunately, I don't see a way to do
this. The API only appears to expose the sampleStart() and sampleEnd()
methods. You can't directly set the start and end times.

Any ideas for a work around on this?

For reference, here is a watered down version of my sampler code:

public SampleResult sample(Entry e) {
   //pool of threads to do sub-requests
   List<Thread> requestRunners = new ArrayList<Thread>();

   //4 because most browsers support 4 simultaneous requests
   for (int i = 0; i < 4; i++)
      requestRunners.add(new Thread(new RequestRunner());


   //start all the sub-requests
   for (Thread runner : requestRunners)

   //wait for all sub-requests to finish
   for (Thread runner : requestRunners) {
   //this doesn't work right because too much time has passed since the last
sub-request came back in and the next line of code
   return result;

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message