You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by "BOLB (Bohdan L Bodnar)" <BO...@panduit.com> on 2012/12/07 21:58:13 UTC
measuring time in "while" loop
Greetings!
Here is the problem:
I've HTTP-based API calls to a particular system. The system returns an error code that is either negative (for success) or greater than zero (indicating the requested operation has been started).
In the event the return code is greater than zero, I poll the system using a "while" loop. In one of the calls, I'm using the following in the "while" controller: ${__javaScript(${DEL_CAT1_STATUS} > 0)}. The portion of the script looks as follows:
WHILE CONTROLLER
HTTP REQUEST (this is the API call)
REGULAR EXPRESSION EXTRACTOR (to get "DEL_CAT1_STATUS")
DELAY
I want to measure the total time spent in this "while" loop (this is for statistical analysis). High accuracy isn't all that important - the loop will spin at least a dozen or so times and the delay probably swamp measurement error.
Any suggestions?
Thanks,
Bo
[LearnAboutUPI-icons-notrademrks]<http://www.panduit.com/upi>
[Panduit-logo-w-bp-notrademrks]<http://www.panduit.com/>
RE: measuring time in "while" loop
Posted by "BOLB (Bohdan L Bodnar)" <BO...@panduit.com>.
Thank you VERY much for your kind assistance, Sebb. I ended using the Transaction Controller suggestion - this resulted in a very simple mechanism for recording total time spent in the loop.
Best regards,
Bo
-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com]
Sent: Tuesday, December 11, 2012 5:53 PM
To: JMeter Users List
Subject: Re: measuring time in "while" loop
On 11 December 2012 23:27, BOLB (Bohdan L Bodnar) <BO...@panduit.com> wrote:
> I'm doing something incorrectly, but I cannot figure out what:
>
> 1). A "User Parameter" block is used to assign the system to variable "START" using ${__time(,)} at the beginning of the loop and the same is done to variable "END" at the end of the loop.
>
> 2). A Beanshell Sampler is used to write to a file; the sample code is:
>
> ${__longSum(${END},-${START},output1)};
> f = new FileOutputStream("c:\\file1.txt");
> p = new PrintStream(f);
> this.interpreter.setOut(p);
> print(output1);
>
> Upon execution, the following error message is received:
>
> Response code: 500
> Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``0; f = new FileOutputStream("c:\file1.txt"); p = new PrintStream(f); this.interp . . . '' : Object constructor
>
>
> What, if anything, am I doing incorrectly (btw, this is jmeter 2.8)?
Try using the Java sampler instead; it's much simpler.
Just reference the variable in the sample data or the label and it will appear in the sample results.
Alternatively, see:
http://jmeter.apache.org/usermanual/listeners.html#sample_variables
which is simpler still
> Thanks,
>
> Bo
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Tuesday, December 11, 2012 2:01 PM
> To: JMeter Users List
> Subject: Re: measuring time in "while" loop
>
>> use it in a Java Sampler.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: measuring time in "while" loop
Posted by sebb <se...@gmail.com>.
On 11 December 2012 23:27, BOLB (Bohdan L Bodnar) <BO...@panduit.com> wrote:
> I'm doing something incorrectly, but I cannot figure out what:
>
> 1). A "User Parameter" block is used to assign the system to variable "START" using ${__time(,)} at the beginning of the loop and the same is done to variable "END" at the end of the loop.
>
> 2). A Beanshell Sampler is used to write to a file; the sample code is:
>
> ${__longSum(${END},-${START},output1)};
> f = new FileOutputStream("c:\\file1.txt");
> p = new PrintStream(f);
> this.interpreter.setOut(p);
> print(output1);
>
> Upon execution, the following error message is received:
>
> Response code: 500
> Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``0; f = new FileOutputStream("c:\file1.txt"); p = new PrintStream(f); this.interp . . . '' : Object constructor
>
>
> What, if anything, am I doing incorrectly (btw, this is jmeter 2.8)?
Try using the Java sampler instead; it's much simpler.
Just reference the variable in the sample data or the label and it
will appear in the sample results.
Alternatively, see:
http://jmeter.apache.org/usermanual/listeners.html#sample_variables
which is simpler still
> Thanks,
>
> Bo
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Tuesday, December 11, 2012 2:01 PM
> To: JMeter Users List
> Subject: Re: measuring time in "while" loop
>
>> use it in a Java Sampler.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
RE: measuring time in "while" loop
Posted by "BOLB (Bohdan L Bodnar)" <BO...@panduit.com>.
I'm doing something incorrectly, but I cannot figure out what:
1). A "User Parameter" block is used to assign the system to variable "START" using ${__time(,)} at the beginning of the loop and the same is done to variable "END" at the end of the loop.
2). A Beanshell Sampler is used to write to a file; the sample code is:
${__longSum(${END},-${START},output1)};
f = new FileOutputStream("c:\\file1.txt");
p = new PrintStream(f);
this.interpreter.setOut(p);
print(output1);
Upon execution, the following error message is received:
Response code: 500
Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``0; f = new FileOutputStream("c:\file1.txt"); p = new PrintStream(f); this.interp . . . '' : Object constructor
What, if anything, am I doing incorrectly (btw, this is jmeter 2.8)?
Thanks,
Bo
-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com]
Sent: Tuesday, December 11, 2012 2:01 PM
To: JMeter Users List
Subject: Re: measuring time in "while" loop
> use it in a Java Sampler.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: measuring time in "while" loop
Posted by sebb <se...@gmail.com>.
> use it in a Java Sampler.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
RE: measuring time in "while" loop
Posted by "BOLB (Bohdan L Bodnar)" <BO...@panduit.com>.
Thank you, Sebb!
One more question: I want to store these times with timestamp (e.g., via the simple data writer). I don't see a way of doing this (this could be lack of my knowledge of jmeter's features). For example, if the loop spins X times, I want to store the starting time of the loop, the total time spent in the loop, and a predetermined label name for this loop. Any advice on how to do this is greatly appreciated.
Thank you, again,
Bo
-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com]
Sent: Friday, December 07, 2012 7:24 PM
To: JMeter Users List
Subject: Re: measuring time in "while" loop
On 7 December 2012 20:58, BOLB (Bohdan L Bodnar) <BO...@panduit.com> wrote:
>
> Greetings!
>
>
>
> Here is the problem:
>
>
>
> I've HTTP-based API calls to a particular system. The system returns an error code that is either negative (for success) or greater than zero (indicating the requested operation has been started).
>
> In the event the return code is greater than zero, I poll the system using a "while" loop. In one of the calls, I'm using the following in the "while" controller: ${__javaScript(${DEL_CAT1_STATUS} > 0)}. The portion of the script looks as follows:
>
>
START = ${__time}
> WHILE CONTROLLER
>
> HTTP REQUEST (this is the API call)
>
> REGULAR EXPRESSION EXTRACTOR (to get "DEL_CAT1_STATUS")
>
> DELAY
>
>
ELAPSED = ${__longSum($__time,-${START})}
> I want to measure the total time spent in this "while" loop (this is for statistical analysis). High accuracy isn't all that important - the loop will spin at least a dozen or so times and the delay probably swamp measurement error.
>
>
>
> Any suggestions?
See above.
You could then log it using the log function or use it in a Java Sampler.
Or of course you could enclose the entire loop in a Transaction Controller.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: measuring time in "while" loop
Posted by sebb <se...@gmail.com>.
On 7 December 2012 20:58, BOLB (Bohdan L Bodnar) <BO...@panduit.com> wrote:
>
> Greetings!
>
>
>
> Here is the problem:
>
>
>
> I've HTTP-based API calls to a particular system. The system returns an error code that is either negative (for success) or greater than zero (indicating the requested operation has been started).
>
> In the event the return code is greater than zero, I poll the system using a "while" loop. In one of the calls, I'm using the following in the "while" controller: ${__javaScript(${DEL_CAT1_STATUS} > 0)}. The portion of the script looks as follows:
>
>
START = ${__time}
> WHILE CONTROLLER
>
> HTTP REQUEST (this is the API call)
>
> REGULAR EXPRESSION EXTRACTOR (to get “DEL_CAT1_STATUS”)
>
> DELAY
>
>
ELAPSED = ${__longSum($__time,-${START})}
> I want to measure the total time spent in this “while” loop (this is for statistical analysis). High accuracy isn’t all that important – the loop will spin at least a dozen or so times and the delay probably swamp measurement error.
>
>
>
> Any suggestions?
See above.
You could then log it using the log function or use it in a Java Sampler.
Or of course you could enclose the entire loop in a Transaction Controller.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org