jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Set sampler start/end time directly
Date Wed, 29 Jun 2011 18:52:47 GMT
On 29 June 2011 19:48, E S <electric.or.sharp@gmail.com> wrote:
> I can, I just have write code to coordinate the child threads so that the
> first one that runs starts the parent result timer and and none of the
> others do. I was just hoping the system would take care of that for me like
> it did with the end time. Not a huge deal.

Or just have the parent sampler start the timer just before starting
the child threads.

> On Wed, Jun 29, 2011 at 1:39 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 29 June 2011 17:41, E S <electric.or.sharp@gmail.com> wrote:
>> > I see, so call addSubResult() will adjust the parent's end time for you.
>> > Well that solves half the problem. Of course you still have the problem
>> > where the child threads don't start until long after the parent results's
>> > sampleStart() is called which could also lead to a large discrepancy in
>> > time. I would think that addSubResult() would adjust the parent start
>> time
>> > in addition to the end time, but it doesn't seem to. Maybe I'm
>> > misunderstanding how you use results and subresults?
>>
>> If you are writing your own sampler, you can start the child threads
>> at the same time as starting the main sample.
>>
>> > On Tue, Jun 28, 2011 at 5:26 PM, sebb <sebbaz@gmail.com> wrote:
>> >
>> >> On 28 June 2011 23:18, E S <electric.or.sharp@gmail.com> wrote:
>> >> > 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.
>> >>
>> >> What timer?
>> >>
>> >> > 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.
>> >>
>> >> That is deliberate.
>> >>
>> >> > Any ideas for a work around on this?
>> >>
>> >>
>> >>
>> http://jakarta.apache.org/jmeter/api/org/apache/jmeter/samplers/SampleResult.html#addSubResult%28org.apache.jmeter.samplers.SampleResult%29
>> >>
>> >> should do what you need.
>> >>
>> >> >
>> >> > 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());
>> >> >
>> >> >   result.sampleStart();
>> >> >
>> >> >   //start all the sub-requests
>> >> >   for (Thread runner : requestRunners)
>> >> >      runner.start();
>> >> >
>> >> >   //wait for all sub-requests to finish
>> >> >   for (Thread runner : requestRunners) {
>> >> >      runner.join();
>> >> >   //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
>> >> >   result.sampleEnd();
>> >> >   result.setSuccessful(allResultsSuccessful(result.getSubResults()));
>> >> >   return result;
>> >> > }
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message