On 6 January 2011 14:42, zhouyuan <[email protected]> wrote:
>
>
> sebb-2-2 wrote:
>>
>> On 5 January 2011 11:09, zhouyuan <[email protected]> wrote:
>>>
>>> Hi guys,
>>>
>>> I want to use a BeanShell Timer to get dynamical think time in
>>> transactions.
>>> Now I'm trying to use BeanShell PreProcessor and BeanShell PostProcessor
>>> in
>>> a transaction to get the start and end timestamp like the following:
>>>
>>> long time2;
>>> ${__time(,time2)};
>>> ${__log(${time2},OUT)};
>>> long response = Long.parseLong(${time2})-Long.parseLong(${time1});
>>> long response1 = ${time2}-${time1};
>>> ${__log(${response},OUT)};
>>> ${__log(${response1},OUT)};
>>>
>>> But it always logs an error like this:
>>>
>>> 2011/01/05 17:53:20 WARN  - jmeter.extractor.BeanShellPostProcessor: P
>>> roblem in BeanShell script org.apache.jorphan.util.JMeterException: Error
>>>  invoking bsh method: eval Parse error at line 2, column 1 : Error or
>>> number too big for integer type: 1294221200196
>>>
>>> How could I defined the variables in long format or is there other ways
>>> to
>>> get transaction time and use it in a timer?
>>
>> What calculation are you actually trying to perform?
>> I.e. how is the think time to be calculated?
>> What does it depend on?
>>
>> If you tell us that it might be easier to advise what approach to take.
>>
>>> Many thanks in advance!
>>> --
>>> View this message in context:
>>> http://jmeter.512774.n5.nabble.com/How-to-get-transaction-time-into-a-user-defined-variable-tp3328587p3328587.html
>>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>
> I want to calculate the think time like this:
> ( Const time - Response time of each transaction ) * Random Value

OK, that should be easy to calculate.

So do you want to add the delay after each sample, based on the
response time of the sample?

Timers are applied before samplers, so what you need to do is (pseudo-code):

If PREV != null
then
    delay = (const - PREV.elapsed) * Random Value
else
    delay = 0
endif

This is easy in BSH, as JMeter provides access to the previous sample
result in in "prev" variable.

if (prev == null) {
    return 0;
} else {
    return (1234 - prev.getTime()) * Math.random();
}

(not tested, but you get the idea)
> --
> View this message in context: 
> http://jmeter.512774.n5.nabble.com/How-to-get-transaction-time-into-a-user-defined-variable-tp3328587p3330495.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to