Return-Path: Delivered-To: apmail-jakarta-jmeter-user-archive@www.apache.org Received: (qmail 49095 invoked from network); 6 Jan 2011 15:10:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Jan 2011 15:10:40 -0000 Received: (qmail 59803 invoked by uid 500); 6 Jan 2011 15:10:40 -0000 Delivered-To: apmail-jakarta-jmeter-user-archive@jakarta.apache.org Received: (qmail 59748 invoked by uid 500); 6 Jan 2011 15:10:40 -0000 Mailing-List: contact jmeter-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "JMeter Users List" Reply-To: "JMeter Users List" Delivered-To: mailing list jmeter-user@jakarta.apache.org Received: (qmail 59735 invoked by uid 99); 6 Jan 2011 15:10:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jan 2011 15:10:39 +0000 X-ASF-Spam-Status: No, hits=2.3 required=10.0 tests=SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of yzhou@microstrategy.com does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jan 2011 15:10:33 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1ParTg-00017m-GK for jmeter-user@jakarta.apache.org; Thu, 06 Jan 2011 07:10:12 -0800 Date: Thu, 6 Jan 2011 07:10:12 -0800 (PST) From: zhouyuan To: jmeter-user@jakarta.apache.org Message-ID: <1294326612496-3330545.post@n5.nabble.com> In-Reply-To: <4D257C12.5030306@mpexnet.de> References: <1294225746945-3328587.post@n5.nabble.com> <4D245418.8040606@mpexnet.de> <1294226854405-3328614.post@n5.nabble.com> <4D2457FC.6040009@mpexnet.de> <1294292623621-3329998.post@n5.nabble.com> <4D257C12.5030306@mpexnet.de> Subject: Re: How to get transaction time into a user defined variable? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Felix Frank-2 wrote: > > 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: jmeter-user-unsubscribe@jakarta.apache.org >>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org >>> >>> >>> >> >> 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: jmeter-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org > > > I tried to create UDVs first and then do the computations above, but I still can't get any output using __log function in the console. Could you give me an example that works fine in basic computations and we can also watch the variables in some way? Thanks! -- View this message in context: http://jmeter.512774.n5.nabble.com/How-to-get-transaction-time-into-a-user-defined-variable-tp3328587p3330545.html Sent from the JMeter - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: jmeter-user-help@jakarta.apache.org