You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Janine DeBeradinis <jd...@higherone.com> on 2011/05/03 18:34:14 UTC

long\int Sum fuction

Hello -

It appears as if the _intSum or _longSum functions do not work with numbers that contain a decimal (i.e. 117.51).  When I attempt to run a script that uses one of these functions with a number that contains a decimal, I get a compilation error and a java.lang.NumberFormatException error in the logs.  Can JMeter not add these types of numbers?  Or, is there another function that I can use?

Thank you.
Janine

Re: long\int Sum fuction

Posted by sebb <se...@gmail.com>.
On 3 May 2011 18:24, Bruce Ide <fl...@gmail.com> wrote:
> ints and longs don't do real numbers. I don't see a function to use floats,
> which seems odd to me.

The functions are generally used with counters and pauses etc., which
only need integral values.

> I'm sure you could add up your numbers with a BSF
> sampler, though. Something like
>
> Float myFloat = ${varWithReals} // Or use
> Float.parseFloat(vars.get("varWithReals"));
> Float accumulate = ${accumulatorVar} + myFloat;
> vars.put("accumulatorVar", Float.toString(accumulate));
>
> It's kind of a long way to go to get that, though. Perhaps someone can
> suggest an easier method.

There are several scripting functions, see:

http://jakarta.apache.org/jmeter/usermanual/functions.html#__jexl
http://jakarta.apache.org/jmeter/usermanual/functions.html#__javaScript
http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell

> You may prefer to use Double than Float, depending on how big/small your
> numbers are.
>
> --
> Bruce Ide
> FlyingRhenquest@gmail.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: long\int Sum fuction

Posted by Bruce Ide <fl...@gmail.com>.
ints and longs don't do real numbers. I don't see a function to use floats,
which seems odd to me. I'm sure you could add up your numbers with a BSF
sampler, though. Something like

Float myFloat = ${varWithReals} // Or use
Float.parseFloat(vars.get("varWithReals"));
Float accumulate = ${accumulatorVar} + myFloat;
vars.put("accumulatorVar", Float.toString(accumulate));

It's kind of a long way to go to get that, though. Perhaps someone can
suggest an easier method.

You may prefer to use Double than Float, depending on how big/small your
numbers are.

-- 
Bruce Ide
FlyingRhenquest@gmail.com