jira-importer opened a new issue, #1357:
URL: https://github.com/apache/httpcomponents-core/issues/1357

   **[Tony 
Poppleton](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=moqtada)**
 opened 
**[HTTPCORE-212](https://issues.apache.org/jira/browse/HTTPCORE-212?redirect=false)**
 and commented
   
   JProfiler highlighted a few minor bottlenecks in HttpCore, and two patches 
are attached.
   
   Neither of these two patches has been benchmarked in a proper fashion, I 
just observed that they dropped of the JProfiler radar (which isn't a thorough 
way of doing this and may be wrong!).  Could someone with a benchmarking suite 
already setup please test these patches for performance to confirm they are 
indeed faster and also if possible ascertain how much faster.
   
   The first patch is to remove the unnecessary creation of a CharArrayBuffer 
in HttpHost.toHostString.  In cases without a port, there is no object creation 
at all now, and in cases with a port then Java string concatenation is used 
(and optimized away in recent JVMs).
   
   The second patch is more involved and affects BasicLineParser.  Given that 
all of my responses are being processed with this class, I decided I should 
look at optimizing it.  The main culprit is the string creation in 
CharArrayBuffer.substringTrimmed which is only required to be able to call the 
Java Integer.parseInt method.  I normally prefer using Java classes where 
possible, however this patch implements a custom parseInt method which also 
removes the need for the indexOf operation (so the CharArrayBuffer/String is 
now only scanned once rather than twice).
   
   
   ---
   
   **Attachments:**
   - 
[BasicLineParser.java.patch](https://issues.apache.org/jira/secure/attachment/12430325/BasicLineParser.java.patch)
 (_12.93 kB_)
   - 
[BasicLineParser.java.patch2](https://issues.apache.org/jira/secure/attachment/12430335/BasicLineParser.java.patch2)
 (_6.19 kB_)
   - 
[BasicLineParser.java.patch3](https://issues.apache.org/jira/secure/attachment/12430470/BasicLineParser.java.patch3)
 (_4.45 kB_)
   - 
[BasicLineParserTest.java](https://issues.apache.org/jira/secure/attachment/12430506/BasicLineParserTest.java)
 (_769 bytes_)
   - 
[HttpHost.java.patch](https://issues.apache.org/jira/secure/attachment/12430324/HttpHost.java.patch)
 (_4.33 kB_)
   - 
[HttpHost.java.patch2](https://issues.apache.org/jira/secure/attachment/12430334/HttpHost.java.patch2)
 (_815 bytes_)
   - 
[HttpHost.java.patch3](https://issues.apache.org/jira/secure/attachment/12430469/HttpHost.java.patch3)
 (_916 bytes_)
   - 
[HttpHostBenchmark.java](https://issues.apache.org/jira/secure/attachment/12430471/HttpHostBenchmark.java)
 (_4.22 kB_)
   
   **Sub-tasks:**
   - [HTTPCORE-213](https://issues.apache.org/jira/browse/HTTPCORE-213) 
CharArrayBuffer.substring(int beginIndex, int endIndex) checks indexes 
unnecessarily
   
   
   **Issue Links:**
   - [HTTPCORE-216](https://issues.apache.org/jira/browse/HTTPCORE-216) Custom 
implementation of parseInt and Integer.toString
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to