On 01/06/2011 06:43 AM, zhouyuan wrote:
> 
> 
> Felix Frank-2 wrote:
>>
>>> No, I'm not trying to chopping off the last three digits, I just want to
>>> get
>>> the transaction time through subtracting the 2 timestamps...but i
>>> couldn't
>>> do any operations on time1 and time2 directly. It seems that the time1
>>> and
>>> time2 are int variables by default? There are some extra lines just
>>> because
>>> I tried to debug this problem.
>>
>> The variables are untyped to BeanShell - their values are inserted
>> verbatim (as numerals) into your script.
>>
>> Your log shows a "number too large" error, hence my suggestion to drop
>> the milliseconds.
>>
>> Your computation of "long response1" should produce a valid timespan in
>> milliseconds, I believe.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
> 
> Hi Felix,
> 
> The problem is that I can't do any computation on time2 and time1, you
> suggest me to drop milliseconds through dividing them by 1000? Or do some
> formatting with the time function?
> I also tried like this:
> int a=1;
> ${__log(${a},OUT)};
> int b=2;
> ${__log(${b},OUT)};
> int c=b-a;
> ${__log(${c},OUT)};
> But the console output is:
> Log: Thread Group 1-1 : ${a}
> Log: Thread Group 1-1 : ${b}
> Log: Thread Group 1-1 : ${c}
> 
> Is there anything wrong with my script?

Careful: ${a} supposes that there is a variable *on the Test Plan level*
that is named a (e.g., created by a RegexExtractor or UserDefinedVariables).

Before Jmeter sends your BSH Script to the interpreter, it substitutes
all occurences of ${a} by the value of this Jmeter variable.

"int a=1" on the other hand creates a variable local to your BSH Script.
The two types of variables can't be mingled.

To manipulate Jmeter variables, use the vars object from BSH.

>From your earlier error logs, I assume time1 and time2 are actual Jmeter
variables. To loose the milliseconds, I suggest using them as strings,
chopping 3 characters using substr() or whatever that is in BSH and then
parse it to a long value.

HTH,
Felix

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

Reply via email to