[ https://issues.apache.org/jira/browse/CXF-3262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jason Downey updated CXF-3262: ------------------------------ Attachment: patch.diff Here's a potential patch for this issue. Now Literal and Variable have a create function which return a UriChunk. Variable creation avoids the throwing of IllegalArgumentException but Literal keeps it for null and blank strings. In this tightly nested loop, public void testURITemplatePerformance() { long startTime = System.currentTimeMillis(); for (long i = 1; i < 900000; i++) new URITemplate("/customers/name/{name}/dep/{department}"); long endTime = System.currentTimeMillis(); System.out.println(endTime - startTime); } the original implementation ran in 26 seconds; the patched version ran in 13 seconds. The savings would have been a lot more if there had been more literals in the URI. > JAX-RS: Performance Improvement: Don't use IllegalArgumentException to > determine if a URI chunk is a variable or literal > ------------------------------------------------------------------------------------------------------------------------ > > Key: CXF-3262 > URL: https://issues.apache.org/jira/browse/CXF-3262 > Project: CXF > Issue Type: Improvement > Components: JAX-RS > Affects Versions: 2.3.1 > Environment: JDK 1.6 > Reporter: Ka-Lok Fung > Priority: Minor > Fix For: 2.3.3 > > Attachments: patch.diff > > Original Estimate: 3h > Remaining Estimate: 3h > > Profiling the Apache CXF JAX-RS code shows that more time than necessary is > being spent in UriChunk.createUriChunk because it uses an > IllegalArgumentException to determine whether a URI chunk should be a literal > or a variable. Creating exceptions is expensive :( > Instead of using IllegalArgumentException, perhaps you can have a method that > is like the following: > public static Variable.create(String uriChunk) > where null will be returned if uriChunk is not a variable. This way you can > avoid the overhead of creating the unnecessary stack trace. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.