>So, you're suggesting that I should learn Jexl so that I can divide one
number by another in JMeter?

Yes you must use javascript, but its stupid simple.  Javascript help on
operators
http://www.w3schools.com/js/js_operators.asp

Functions are very simple

${__jexl(${log1ID}+1)}

>Wow, that's absolutely NOT what I'd expect and I don't see that
mentioned anywhere in the documentation.

I came across this as well.. Basically you can't reference another
variable in a UDV that was defined in that same UDV element.  Things
aren't ready till the end of the element.  sebb added to the
documentation in-progress at that point to help make that clear.  

>*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

It's confusing at first, but once you know what's happening its not so
bad to work with.  You must live with the assumption that if jmeter
doesn't understand the reference, it will just be passed as a literal
string.  This includes undefined variable names or syntax mismatches.
Basically, instead of stopping and erroring, its going to continue and
pass that as a string 'as is' rather then evaluate it.

Common things I found that trip you up
- case sensativity in function and variable names
- the usual { vs ( typos
- typos or mismatches in variable or function names

People are accustomed to the program halting on syntax checking or
references and jmeter simply doesn't do that.  So any errors must be
caught through monitoring the values being used.  Only when you get
invalid parameters in some of the samplers, etc do you typically get an
exception at run time.

The key is to use the debug sampler often when writing the script to
monitor the variables and properties to ensure you are manipulating what
you expect.  Every time I had problems like you described, it was
typically one of the above problems.  The UDV issue of referencing the
variable that was just defined in the same element has been the only
real problem I've encounter.  The rest is just coping with no syntax or
reference checking... So the burden of debugging is on you.

What I would like to see in jmeter though is a element that can be used
just for processing expressions, etc.  It seems many of the functions,
etc are intended to used 'in line' vs the model of modifying variables
and expressions first, then passing them into the samplers/etc. Maybe an
'executor' block :)


----- 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]

Reply via email to