Hi Oleg,

I ran this by Ortwin prior to posting here:

> I ran some quick tests. I just changed the line to:
>   inputStream = new PushbackInputStream(new 
> BufferedInputStream(socket.getInputStream()));
> and left everything else as it is.
> 
> Running 5000 GET requests to a local Tomcat yields:
>   without buffering: 2.6658 ms per request
>   with buffering: 1.7966 ms per request
> 
> That is a good 30 % improvement.

We also saw improvements of this magnitude. 

Thanks,
Bjarne.

>>> [EMAIL PROTECTED] 9/1/2004 1:30:13 PM >>>
Bjarne,

Could you define 'considerably' in some ANSI units? ;-)

I have just recently dealt with this problem. The empirical data that
I
got appears to suggest that there's a (more or less) constant delta in
performance of ~2-3ms, which only makes a difference for relatively
small payloads. For more or less real-life scenarios HttpClient should
be at least as fast or faster than HttpUrlConnection 

http://marc.theaimsgroup.com/?l=httpclient-commons-dev&m=109300858528261&w=2


I'll re-run the tests to see if this change does result in noticeable
performance gains and poke around the Java source code to see if
there's
indeed a reason for PushbackInputStream#unread to be slower than
BufferedInputStream#reset

Thanks

Oleg



On Wed, 2004-09-01 at 18:27, Bjarne Rasmussen wrote:
> We found a small performance discrepancy between Java's
> HttpURLConnection and HttpClient. Disabling stale connection checks
> helps but HttpURLConnection is still faster for small payloads.
Making
> the following change to HttpConnection.java (line 689 in version
2.0.1)
> speeds things up considerably:
> 
>    inputStream = new BufferedInputStream(socket.getInputStream());
> 
> The BufferedInputStream's mark/reset methods can be used in place of
> PushbackInputStream.unread, e.g.:
> 
>     this.socket.setSoTimeout(timeout);
>     inputStream.mark(1);
>     int byteRead = inputStream.read();
>     if (byteRead != -1) {
>        inputStream.reset();
>        LOG.debug("Input data available");
>        result = true;
>     } else {
>        LOG.debug("Input data not available");
>     }
> 
> Thanks,
> Bjarne.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
[EMAIL PROTECTED] 
> For additional commands, e-mail:
[EMAIL PROTECTED] 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED] 
For additional commands, e-mail:
[EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to