Bug 59991 - New function __groovy to evaluate Groovy Script
Summary: New function __groovy to evaluate Groovy Script
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.0
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-11 21:37 UTC by UbikLoadPack support
Modified: 2016-08-12 11:02 UTC (History)
1 user (show)



Attachments
Patch implementing this new feature (11.19 KB, patch)
2016-08-11 21:39 UTC, UbikLoadPack support
Details | Diff
Test plan showing use case and allowing performane comparison (7.86 KB, patch)
2016-08-11 21:40 UTC, UbikLoadPack support
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description UbikLoadPack support 2016-08-11 21:37:36 UTC
Hello,
Currently whenever you want to make some processing and a JMeter function is not available for it, you can only use __BeanShell function.
For example:
- substring
- length
- Maths functions
- + hundreds of examples where you need the power of Java without wanting to use a JSR223TestElement. 
....


Unfortunately Beanshell performances are horrid compared to Groovy ones for example besides the fact that Groovy is now integrated in JMeter, maintained by Apache and very popular and that Beanshell is nearly abandoned.


So we propose to add this function that will work the same way as Beanshell.
Comment 1 UbikLoadPack support 2016-08-11 21:39:41 UTC
Created attachment 34139 [details]
Patch implementing this new feature
Comment 2 UbikLoadPack support 2016-08-11 21:40:36 UTC
Created attachment 34140 [details]
Test plan showing use case and allowing performane comparison
Comment 3 UbikLoadPack support 2016-08-11 21:44:34 UTC
On my machine with a default setup:

TG-Groovy Enabled only:
Generate Summary Results =  20000 in 00:00:00 = 41666.7/s Avg:     0 Min:     0 Max:     2 Err:     0 (0.00%)


TG-Beanshell enabled only:
Generate Summary Results +    891 in 00:00:01 = 1161.7/s Avg:     0 Min:     0 Max:     1 Err:     0 (0.00%) Active: 0 Started: 20 Finished: 20
Generate Summary Results =  40000 in 00:00:16 = 2539.4/s Avg:     0 Min:     0 Max:     2 Err:     0 (0.00%)


This simple benchmark shows that this new __g function is 35 times faster than __BeanShell.
Comment 4 UbikLoadPack support 2016-08-11 21:49:14 UTC
(In reply to UbikLoadPack support from comment #3)
> On my machine with a default setup:
> 
> TG-Groovy Enabled only:
> Generate Summary Results =  20000 in 00:00:00 = 41666.7/s Avg:     0 Min:   
> 0 Max:     2 Err:     0 (0.00%)
> 
> 
> TG-Beanshell enabled only:
> Generate Summary Results +    891 in 00:00:01 = 1161.7/s Avg:     0 Min:    
> 0 Max:     1 Err:     0 (0.00%) Active: 0 Started: 20 Finished: 20
> Generate Summary Results =  40000 in 00:00:16 = 2539.4/s Avg:     0 Min:    
> 0 Max:     2 Err:     0 (0.00%)
> 
> 
> This simple benchmark shows that this new __g function is 35 times faster
> than __BeanShell.

Sorry little mistake for Beanshell:

Generate Summary Results +  17444 in 00:00:13 = 1312.6/s Avg:     0 Min:     0 Max:     2 Err:     0 (0.00%) Active: 10 Started: 10 Finished: 0
Generate Summary Results +   2556 in 00:00:02 = 1296.1/s Avg:     0 Min:     0 Max:     1 Err:     0 (0.00%) Active: 0 Started: 10 Finished: 10
Generate Summary Results =  20000 in 00:00:15 = 1310.4/s Avg:     0 Min:     0 Max:     2 Err:     0 (0.00%)

This simple benchmark shows that this new __g function is 31 times faster
 than __BeanShell.
Comment 5 Sebb 2016-08-12 09:35:08 UTC
This seems fine, but I think it's confusing to use the name '__g'.

The function should be called '__groovy' to align with the other scripting functions.

Also the new file needs the standard AL header.
Comment 6 Philippe Mouawad 2016-08-12 11:02:32 UTC
Author: pmouawad
Date: Fri Aug 12 11:00:39 2016
New Revision: 1756144

URL: http://svn.apache.org/viewvc?rev=1756144&view=rev
Log:
Bug 59991 - New function __groovy to evaluate Groovy Script
Contributed by Ubik Load Pack
Bugzilla Id: 59991

Added:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/Groovy.java   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/functions.xml