You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Deepak Shetty <sh...@gmail.com> on 2016/01/04 17:10:11 UTC

Re: how to use properly vars function

Hi
the ones listed in http://jmeter.apache.org/usermanual/functions.html - The
__time and the __longSum functions

On Thu, Dec 31, 2015 at 10:25 AM, Erez Naim <er...@theneura.com> wrote:

> Deepak, by saying "the standard functions", what do u mean?
>
> On Dec 31, 2015 20:06, Deepak Shetty <sh...@gmail.com> wrote:
> >
> > Hi
> > >vars.put(timestamp_starts,"timestamp_start");
> > This looks wrong - *usually* it should be
> > vars.put("Static Variable name",dynamic); -- i.e. the Key is a static
> > string that you use to name the variable and the value is the part that
> > changes - whereas you are using it in the other way
> >
> > Also there doesnt look to be anything that needs beanshell - are you sure
> > the standard functions dont work for you ?
> >
> >
> >
> > On Thu, Dec 31, 2015 at 8:20 AM, Erez Naim <Er...@theneura.com> wrote:
> >
> > > Hello all,
> > >
> > >
> > >
> > > I am getting timestamp variable from the command line or a default one
> if
> > > none was delivered.
> > >
> > >
> > >
> > > I am using this chunk of code under BeanShellPostProcessor:
> > >
> > > import java.lang.*;
> > >
> > >
> > >
> > > int timestampInt=0;
> > >
> > > String timestamp="";
> > >
> > >
> > >
> > > try{
> > >
> > > timestamp=vars.get("timestamp_start");
> > >
> > > timestampInt = Integer.parseInt(timestamp);
> > >
> > > timestampInt+=1;
> > >
> > > timestamp_start=Integer.toString(timestampInt);
> > >
> > > System.out.println("After incremental of the variable: " +
> > > timestamp_start);
> > >
> > >
> > >
> > > vars.put(timestamp_starts,"timestamp_start");
> > >
> > > timestamp=vars.get("timestamp_starts");
> > >
> > >
> > >
> > >
> > >
> > > }catch (Exception ex){
> > >
> > >     log.warn("Error in my script", ex);
> > >
> > >     throw ex; // elsewise JMeter will "swallow" the above exception
> > >
> > > }
> > >
> > >
> > >
> > >
> > >
> > > Then I am using a while controller where stop condition is as follows:
> > >
> > > ${__javaScript("${timestamp_start}" <=  "${timestamp_end}")}
> > >
> > >
> > >
> > > However I noticed that timestamp doesn't increment and I get the same
> > > timestamp.
> > >
> > >
> > >
> > > Any idea what could be the problem?
> > >
> > >
> > >
> > > Thanks,
> > >
> > >
> > >
> > > Erez Naim  |  QA Lead  |
> > >
> > > [image: cid:image004.png@01D01E1B.5F153500]
> > >
> > > EL AL 2 Street | Herzliya
> > > mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
> > >
> > >
> > >
> > > website <http://www.theneura.com/>  |  blog <
> http://www.startupbitz.com/>
> > >  |  twitter <https://twitter.com/intent/user?screen_name=theneura>
> |  map
> > > <http://goo.gl/maps/ZRkg5>
> > >
> > >
> > >
> > >
> > >
>