hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: Where are the response bits being read over the wire?
Date Fri, 14 May 2004 02:48:01 GMT
Hi Steve,

Could it be that most of the responses are less that 4KB?  This would 
explain the zero times since the timer does not start until after the 
first read.  If would suggest setting responseEnd before the while 
loop.  Also, it could be that System.currentTimeMillis() does not 
provide enough resolution to measure the time accurately.

Mike

On May 13, 2004, at 5:22 PM, Steve Johnson wrote:

> Hi All,
>
> We are extending classes in an initail effort to instrument DNS, 
> connect, response(first buffer read), and
> download.
> The DNS and connect looks pretty good.
>
> Where are the bits actually being retrieved over the wire?
> Overriding HttpMethodBase. byte[] getResponseBody() and adding 
> response and download times returns reasonable
> looking response times, but almost all the download duration times are 
> 0. Here is the current code. It is
> derived from GetMethod.java
>
>     public byte[] getResponseBody() {
>         if (this.responseBody == null) {
>             try {
>                 boolean firstReadDone = false;
>                 InputStream instream = getResponseBodyAsStream();
>                 if (instream != null) {
>                     LOG.debug("Buffering response body");
>                     ByteArrayOutputStream outstream = new 
> ByteArrayOutputStream();
>                     byte[] buffer = new byte[4096];
>                     int len;
>                     while ((len = instream.read(buffer)) > 0) {
>                         outstream.write(buffer, 0, len);
>                         if ( !firstReadDone ) {
>                             responseEnd = System.currentTimeMillis();
>                         }
>                         
> System.out.println("ApacheGetMethod.getResponseBody() path: " + 
> getPath() + " bytes
> read: " + len );
>                         firstReadDone = true;
>                     }
>                     outstream.close();
>                     setResponseStream(null);
>                     this.responseBody = outstream.toByteArray();
>                 }
>             } catch (IOException e) {
>                 LOG.error("I/O failure reading response body", e);
>                 this.responseBody = null;
>             }
>             long downloadEnd = System.currentTimeMillis();
>             downloadDuration = downloadEnd - responseEnd;
>             System.out.println("ApacheGetMethod.getResponseBody() 
> path: " + getPath() + " responseEnd: " +
> responseEnd + " downloadEnd: " + downloadEnd + " downloadDuration: " + 
> downloadDuration );
>         }
>         return this.responseBody;
>     }
>
> Thanks for any ideas or information,
>
> Steve
>
> Steve Johnson
> Software Engineer
> Mercury Interactive
> 720 564 - 6532
> USA, Canada and the Americas
> 720 564-6620
> Hours: M-F 08:00-17:00 MST (Mountain Standard Time)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  <http://www.mercuryinteractive.com> http://www.mercuryinteractive.com
> Looking for Answers to your SiteScope or SiteSeer questions?        
> <http://support.mercuryinteractive.com>
> http://support.mercuryinteractive.com
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message