On 11/04/2008, Dan Tripp <[EMAIL PROTECTED]> wrote:
> > You can use intSum() for adding/subtracting numbers, otherwise use Jexl.
>
>
>
>
> So, you're suggesting that I should learn Jexl so that I can divide one
> number by another in JMeter?
No need, you already know the mathematical symbols.
> There's no simple way to evaluate simple mathematic expressions?
>
>
Yes there is a simple way - use Jexl or Javascript or BeanShell ...
${__jexl(6*7)}
Similarly for the others.
I'll add some examples to the doc.
>
>
>
> > If you put sql in a separate UDV it should work.
>
>
>
> Wow, that's absolutely NOT what I'd expect and I don't see that mentioned
> anywhere in the documentation.
>
It has been documented and will be in the next version.
I think the UDV was originally designed for fixed values.
>
>
>
> > var5 ${__time(YMD)}
>
Works for me.
>
>
> Why doesn't *that* work?
No idea. What do you see for the var5 reference?
> I took a couple of these samples directly from the documentation, including
> the assembled sql query one.
>
>
Works for me as well.
Though in fact eval() is not needed in that case.
The example should read
if SQL="select ${column} from ${table}" then ${__eval(${SQL})} etc;
i.e. eval is for a nested evaluation.
>
>
>
> > It should work almost anywhere.
>
>
>
> *Should* work and *does* work are totally different things. My experience
> with JMeter suggests that JMeter is remarkably inconsistent as to what text
> fields/etc. are actually interpreted. From a User perspective, this is
> convoluted and confusing.
I disagree.
>
> - Dan
>
>
>
>
> ----- Original Message ----
> From: sebb <[EMAIL PROTECTED]>
> To: JMeter Users List <[email protected]>
> Sent: Thursday, April 10, 2008 6:20:03 PM
> Subject: Re: Understanding How to Twiddle Values in JMeter
>
> On 11/04/2008, Dan Tripp <[EMAIL PROTECTED]> wrote:
> > Howdy All,
> >
> > I'm trying to perform some simple calculations with data I've extracted
> using an HTTP sampler and the Regular Expression Extractor. I have no
> problem getting the values I need/want/expect from the Regex, but I can't
> seem to add numbers together, and I can't seem to figure out *WHERE* the
> calculations should go.
> >
> > The simplest sample I've come up with looks like this:
> >
> > Test Plan
> > + Thread Group
> > - User Defined Variables
> > - Debug Sampler
> > - View Results Tree
> > Workbench
> >
> > In User Defined Variables, I have:
> >
> > Name Value
> > ====== ================================
> > var1 __eval(30 + 6)
>
> __eval() does not evaluate numeric expressions.
>
> You can use intSum() for adding/subtracting numbers, otherwise use Jexl.
>
> > var2 ${__eval(30 + 6)}
> > var3 10 / 4
> > var4 ${__eval(10 / 4)}
> > var5 ${__time(YMD)}
> > column uname
> > table users
> > sql SELECT ${column} FROM ${table}
> >
> > The output I see from the Debug Sampler is NOT what I'd expect:
> >
> > var1 = __eval(30 + 6)
> > var2 = ${__eval(30 + 6)}
> > - I was hoping to get "36"
> >
> > var3 = 10 / 4
> > var4 = ${__eval(10 / 4)}
> > - I was hoping to get "2"
> >
> > var5 = ${__time(YMD)}
> > - I was hoping to get "20080410"
> >
> > column = uname
> > table = users
> > sql = SELECT ${column} FROM ${table}
> > I was hoping to get "SELECT uname FROM users"
>
> UDV variables are not defined until the entire element has been processed.
> If you put sql in a separate UDV it should work.
>
> > It may be the case that User Defined Variables is just a convenience
> component which makes it easier to define variables than it would be to
> import them from a text file and that my use of this component is
> wayward/errant. However, I don't know where the heck to put this stuff if
> this is the wrong place.
> >
> > Further, I don't seem to be able to get the expected values when I put
> these types of expressions in other components... UNLESS I put them in the
> title. The ${__time(YMD)} works great if I put it in a COMPONENT LABEL (ie.-
> I name that component "Today is ${__time(YMD)}" I'll see "Today is 20080410"
> in the results), but doesn't want to do what I'm expecting when I stick it
> anywhere else. That makes absolutely no sense to me. How/what am I not
> understanding?
>
> It should work almost anywhere.
>
> >
> > I'd greatly appreciate any guidance/ pointers/ references to anything
> that'll help me accomplish this.
> >
> > Regards,
> >
> >
> > - Dan
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]