jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1854669 - in /jmeter/trunk: bin/jmeter.properties src/components/org/apache/jmeter/extractor/JoddExtractor.java xdocs/changes.xml xdocs/usermanual/properties_reference.xml
Date Sat, 02 Mar 2019 20:02:41 GMT
Author: pmouawad
Date: Sat Mar  2 20:02:41 2019
New Revision: 1854669

URL: http://svn.apache.org/viewvc?rev=1854669&view=rev
Log:
Bug 63178 - CSS Selector Extractor : Improve performance of JODD (JoddExtractor) based implementation
Bugzilla Id: 63178

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/components/org/apache/jmeter/extractor/JoddExtractor.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1854669&r1=1854668&r2=1854669&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sat Mar  2 20:02:41 2019
@@ -1018,6 +1018,12 @@ csvdataset.file.encoding_list=UTF-8|UTF-
 #---------------------------------------------------------------------------
 # Miscellaneous configuration
 #---------------------------------------------------------------------------
+
+# Size of cache used by CSS Selector Extractor (for JODD implementation only) 
+# to store parsed CSS Selector expressions.
+#cssselector.parser.cache.size=400
+
+
 # Used to control what happens when you start a test and
 # have listeners that could overwrite existing result files
 # Possible values:

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/JoddExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/JoddExtractor.java?rev=1854669&r1=1854668&r2=1854669&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/JoddExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/JoddExtractor.java Sat Mar  2
20:02:41 2019
@@ -21,8 +21,14 @@ package org.apache.jmeter.extractor;
 import java.util.List;
 
 import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.util.JOrphanUtils;
 
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+
+import jodd.csselly.CSSelly;
+import jodd.csselly.CssSelector;
 import jodd.lagarto.dom.LagartoDOMBuilder;
 import jodd.lagarto.dom.Node;
 import jodd.lagarto.dom.NodeSelector;
@@ -39,9 +45,12 @@ public class JoddExtractor implements Ex
     private static final long serialVersionUID = -7235814605293262972L;
 
     private static final String CACHE_KEY_PREFIX = JoddExtractor.class.getName()+"_PARSED_BODY";
-    
+    private static final LoadingCache<String, List<List<CssSelector>>>
CSS_SELECTOR_CACHE;
     static {
         LoggerFactory.setLoggerProvider(Slf4jLogger.PROVIDER);
+        final int cacheSize = JMeterUtils.getPropDefault(
+                    "cssselector.parser.cache.size", 400);
+        CSS_SELECTOR_CACHE = Caffeine.newBuilder().maximumSize(cacheSize).build(CSSelly::parse);
     }
 
     public JoddExtractor() {
@@ -70,7 +79,9 @@ public class JoddExtractor implements Ex
             jodd.lagarto.dom.Document doc = domBuilder.parse(inputString);
             nodeSelector = new NodeSelector(doc);
         }
-        List<Node> elements = nodeSelector.select(expression);
+        
+        List<List<CssSelector>> cssSelectors = CSS_SELECTOR_CACHE.get(expression);
+        List<Node> elements = nodeSelector.select(cssSelectors);
         for (Node element : elements) {
             if (matchNumber <= 0 || found != matchNumber) {
                 result.add(extractValue(attribute, element));

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1854669&r1=1854668&r2=1854669&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sat Mar  2 20:02:41 2019
@@ -93,6 +93,7 @@ Summary
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
+    <li><bug>63178</bug>CSS Selector Extractor : Improve performance of
JODD (JoddExtractor) based implementation</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1854669&r1=1854668&r2=1854669&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sat Mar  2 20:02:41 2019
@@ -1295,6 +1295,10 @@ JMETER-SERVER</source>
 </section>
 <section name="&sect-num;.35 Miscellaneous configuration" anchor="miscellaneous">
 <properties>
+<property name="cssselector.parser.cache.size">
+    Size of cache used by <code>CSS Selector Extractor</code> (for JODD implementation
only) to store parsed CSS Selector expressions.<br/>
+    Defaults to: <code>400</code>
+</property>
 <property name="resultcollector.action_if_file_exists">
     Used to control what happens when you start a test and have listeners that could overwrite
existing result files.<br/>
     Possible values:



Mime
View raw message