You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Philippe Mouawad <ph...@gmail.com> on 2012/11/05 21:08:10 UTC

Substring

Hello,
I am working currently on a test where I need substring function.
I see it seems to require either javascript or beanshell, wouldn't it be
useful to have a jmeter function ?

If you are ok, i will implement it and raise a bugzilla.

Regards
Philippe


-- 
Cordialement.
Philippe Mouawad.

Re: Substring

Posted by sebb <se...@gmail.com>.
On 6 November 2012 12:00, Shmuel Krakower <sh...@gmail.com> wrote:
> Hi Sebb,
> Thats a good point. One of the good things about JMeter is that it doesnt
> bring a new scripting language and this makes it easier for other people to
> use, so each can implement its own stuff/libraries with his preferred
> language.
>
> On the other hand, as a jmeter user, i find some of the "built in"
> functions handy in many of my scripts.
>
> Where should be the limit between creating more handy jmeter functions to
> not creating too much of those?

It depends.

Various factors to consider:
- is the function generally useful, i.e. how many scripts are likely to need it?
- is there a work-round, e.g. pre-process the data?
- is the function is very difficult to code using scripting?
- is the function is too expensive when using scripting?

There are probably other factors I've omitted; some of the above are
not clear-cut either.

> בתאריך 2012 11 6 13:49, מאת "sebb" <se...@gmail.com>:
>
>> On 6 November 2012 06:49, Philippe Mouawad <ph...@gmail.com>
>> wrote:
>> > Use case is the following.
>> > A search screen with auto complete feature that triggers on first 3
>> letters
>> > then on next type.
>> >
>> > So I use a csv for words to search and I need substring to simulate
>> > typeahead/autocomplete calls.
>>
>> If I were doing that test I'd probably put the substring in the CSV
>> file - cheaper to do it before the test.
>>
>> > Note that I succeed doing it with beanshell preprocessor but I find it a
>> > bit too hard for just that and not great for performances.
>>
>> It's quite easy to set up BeanShell functions in a startup script
>> which should improve performance.
>>
>> I.e. define the property:
>>
>> beanshell.function.init=BeanShellFunction.bshrc
>>
>> and create the function:
>>
>> String substring(str,beg,end) {
>>   return s.substring(str,beg,end);
>> }
>>
>> I'm not saying we should not add more functions, but we need to be
>> careful not to add lots of special-purpose functions that are rarely
>> used but still require testing, maintaining and documenting. Also the
>> user has to read more documentation.
>>
>> > Regards
>> > Philippe
>> >
>> > On Tuesday, November 6, 2012, sebb wrote:
>> >
>> >> On 5 November 2012 20:08, Philippe Mouawad <philippe.mouawad@gmail.com
>> <javascript:;>>
>> >> wrote:
>> >> > Hello,
>> >> > I am working currently on a test where I need substring function.
>> >> > I see it seems to require either javascript or beanshell, wouldn't it
>> be
>> >> > useful to have a jmeter function ?
>> >> >
>> >> > If you are ok, i will implement it and raise a bugzilla.
>> >>
>> >> Is your use case generally applicable?
>> >>
>> >> If so, then OK, otherwise it is just bloat.
>> >>
>> >> > Regards
>> >> > Philippe
>> >> >
>> >> >
>> >> > --
>> >> > Cordialement.
>> >> > Philippe Mouawad.
>> >>
>> >
>> >
>> > --
>> > Cordialement.
>> > Philippe Mouawad.
>>

Re: Substring

Posted by Shmuel Krakower <sh...@gmail.com>.
Hi Sebb,
Thats a good point. One of the good things about JMeter is that it doesnt
bring a new scripting language and this makes it easier for other people to
use, so each can implement its own stuff/libraries with his preferred
language.

On the other hand, as a jmeter user, i find some of the "built in"
functions handy in many of my scripts.

Where should be the limit between creating more handy jmeter functions to
not creating too much of those?
בתאריך 2012 11 6 13:49, מאת "sebb" <se...@gmail.com>:

> On 6 November 2012 06:49, Philippe Mouawad <ph...@gmail.com>
> wrote:
> > Use case is the following.
> > A search screen with auto complete feature that triggers on first 3
> letters
> > then on next type.
> >
> > So I use a csv for words to search and I need substring to simulate
> > typeahead/autocomplete calls.
>
> If I were doing that test I'd probably put the substring in the CSV
> file - cheaper to do it before the test.
>
> > Note that I succeed doing it with beanshell preprocessor but I find it a
> > bit too hard for just that and not great for performances.
>
> It's quite easy to set up BeanShell functions in a startup script
> which should improve performance.
>
> I.e. define the property:
>
> beanshell.function.init=BeanShellFunction.bshrc
>
> and create the function:
>
> String substring(str,beg,end) {
>   return s.substring(str,beg,end);
> }
>
> I'm not saying we should not add more functions, but we need to be
> careful not to add lots of special-purpose functions that are rarely
> used but still require testing, maintaining and documenting. Also the
> user has to read more documentation.
>
> > Regards
> > Philippe
> >
> > On Tuesday, November 6, 2012, sebb wrote:
> >
> >> On 5 November 2012 20:08, Philippe Mouawad <philippe.mouawad@gmail.com
> <javascript:;>>
> >> wrote:
> >> > Hello,
> >> > I am working currently on a test where I need substring function.
> >> > I see it seems to require either javascript or beanshell, wouldn't it
> be
> >> > useful to have a jmeter function ?
> >> >
> >> > If you are ok, i will implement it and raise a bugzilla.
> >>
> >> Is your use case generally applicable?
> >>
> >> If so, then OK, otherwise it is just bloat.
> >>
> >> > Regards
> >> > Philippe
> >> >
> >> >
> >> > --
> >> > Cordialement.
> >> > Philippe Mouawad.
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
>

Re: Substring

Posted by sebb <se...@gmail.com>.
On 6 November 2012 06:49, Philippe Mouawad <ph...@gmail.com> wrote:
> Use case is the following.
> A search screen with auto complete feature that triggers on first 3 letters
> then on next type.
>
> So I use a csv for words to search and I need substring to simulate
> typeahead/autocomplete calls.

If I were doing that test I'd probably put the substring in the CSV
file - cheaper to do it before the test.

> Note that I succeed doing it with beanshell preprocessor but I find it a
> bit too hard for just that and not great for performances.

It's quite easy to set up BeanShell functions in a startup script
which should improve performance.

I.e. define the property:

beanshell.function.init=BeanShellFunction.bshrc

and create the function:

String substring(str,beg,end) {
  return s.substring(str,beg,end);
}

I'm not saying we should not add more functions, but we need to be
careful not to add lots of special-purpose functions that are rarely
used but still require testing, maintaining and documenting. Also the
user has to read more documentation.

> Regards
> Philippe
>
> On Tuesday, November 6, 2012, sebb wrote:
>
>> On 5 November 2012 20:08, Philippe Mouawad <philippe.mouawad@gmail.com<javascript:;>>
>> wrote:
>> > Hello,
>> > I am working currently on a test where I need substring function.
>> > I see it seems to require either javascript or beanshell, wouldn't it be
>> > useful to have a jmeter function ?
>> >
>> > If you are ok, i will implement it and raise a bugzilla.
>>
>> Is your use case generally applicable?
>>
>> If so, then OK, otherwise it is just bloat.
>>
>> > Regards
>> > Philippe
>> >
>> >
>> > --
>> > Cordialement.
>> > Philippe Mouawad.
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.

Re: Substring

Posted by Philippe Mouawad <ph...@gmail.com>.
Use case is the following.
A search screen with auto complete feature that triggers on first 3 letters
then on next type.

So I use a csv for words to search and I need substring to simulate
typeahead/autocomplete calls.

Note that I succeed doing it with beanshell preprocessor but I find it a
bit too hard for just that and not great for performances.

Regards
Philippe

On Tuesday, November 6, 2012, sebb wrote:

> On 5 November 2012 20:08, Philippe Mouawad <philippe.mouawad@gmail.com<javascript:;>>
> wrote:
> > Hello,
> > I am working currently on a test where I need substring function.
> > I see it seems to require either javascript or beanshell, wouldn't it be
> > useful to have a jmeter function ?
> >
> > If you are ok, i will implement it and raise a bugzilla.
>
> Is your use case generally applicable?
>
> If so, then OK, otherwise it is just bloat.
>
> > Regards
> > Philippe
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
>


-- 
Cordialement.
Philippe Mouawad.

Re: Substring

Posted by sebb <se...@gmail.com>.
On 5 November 2012 20:08, Philippe Mouawad <ph...@gmail.com> wrote:
> Hello,
> I am working currently on a test where I need substring function.
> I see it seems to require either javascript or beanshell, wouldn't it be
> useful to have a jmeter function ?
>
> If you are ok, i will implement it and raise a bugzilla.

Is your use case generally applicable?

If so, then OK, otherwise it is just bloat.

> Regards
> Philippe
>
>
> --
> Cordialement.
> Philippe Mouawad.

Re: Substring

Posted by Immanuel Hayden <im...@gmail.com>.
+1, iirc I have some code like that myself (the beanshell one ;))


On Mon, Nov 5, 2012 at 9:08 PM, Philippe Mouawad <philippe.mouawad@gmail.com
> wrote:

> Hello,
> I am working currently on a test where I need substring function.
> I see it seems to require either javascript or beanshell, wouldn't it be
> useful to have a jmeter function ?
>
> If you are ok, i will implement it and raise a bugzilla.
>
> Regards
> Philippe
>
>
> --
> Cordialement.
> Philippe Mouawad.
>