You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by Greg Kim <gr...@gmail.com> on 2006/05/18 20:09:08 UTC

Fetcher.java reporting incorrect kb/s?

Hi,

I was just looking at the Fetcher.java code on trunk (r 407599), snippet below.
The total # of bytes is getting multiplied by 8 and the division by
8.0 is missing;

  private void reportStatus() throws IOException {
    String status;
    synchronized (this) {
      long elapsed = (System.currentTimeMillis() - start)/1000;
      status =
        pages+" pages, "+errors+" errors, "
        + Math.round(((float)pages*10)/elapsed)/10.0+" pages/s, "
        + Math.round(((((float)bytes)*8)/1024)/elapsed)+" kb/s, ";
                                                      ^^^
    }
    reporter.setStatus(status);
  }

thanks
greg

Re: Fetcher.java reporting incorrect kb/s?

Posted by Andrzej Bialecki <ab...@getopt.org>.
Greg Kim wrote:
> Hi,
>
> I was just looking at the Fetcher.java code on trunk (r 407599), 
> snippet below.
> The total # of bytes is getting multiplied by 8 and the division by
> 8.0 is missing;
>
>  private void reportStatus() throws IOException {
>    String status;
>    synchronized (this) {
>      long elapsed = (System.currentTimeMillis() - start)/1000;
>      status =
>        pages+" pages, "+errors+" errors, "
>        + Math.round(((float)pages*10)/elapsed)/10.0+" pages/s, "
>        + Math.round(((((float)bytes)*8)/1024)/elapsed)+" kb/s, ";
>                                                      ^^^
>    }
>    reporter.setStatus(status);
>  }

Funny you should mention that just now, I was looking at this 
calculation today - and if you take what is printed literally, it says 
the truth, because it converts bytes (apparently defined as octets) into 
bits (multiply by 8) and then to kilo-bits - although one could say that 
this is not strictly true either, it's rather kibibits - 
http://en.wikipedia.org/wiki/Kibibyte).

So, the calculation is correct, and the unit name "kb/s" correctly uses 
lower-case "b" to signify "bits" rather than "bytes", although many 
people tend to take this as bytes  ...

-- 
Best regards,
Andrzej Bialecki     <><
 ___. ___ ___ ___ _ _   __________________________________
[__ || __|__/|__||\/|  Information Retrieval, Semantic Web
___|||__||  \|  ||  |  Embedded Unix, System Integration
http://www.sigram.com  Contact: info at sigram dot com



Re: Fetcher.java reporting incorrect kb/s?

Posted by Ken Krugler <kk...@transpac.com>.
kb/s is kilobits/second, not kilobytes/second. See 
<http://en.wikipedia.org/wiki/Kilobits>.

I agree that using the more explicit kbits/s would be better.

Related micro-nit...least according to 
http://en.wikipedia.org/wiki/Kilobit_per_second) it should be /1000, 
not /1024.

-- Ken

>I was just looking at the Fetcher.java code on trunk (r 407599), 
>snippet below.
>The total # of bytes is getting multiplied by 8 and the division by
>8.0 is missing;
>
>  private void reportStatus() throws IOException {
>    String status;
>    synchronized (this) {
>      long elapsed = (System.currentTimeMillis() - start)/1000;
>      status =
>        pages+" pages, "+errors+" errors, "
>        + Math.round(((float)pages*10)/elapsed)/10.0+" pages/s, "
>        + Math.round(((((float)bytes)*8)/1024)/elapsed)+" kb/s, ";
>                                                      ^^^
>    }
>    reporter.setStatus(status);
>  }
>
>thanks
>greg


-- 
Ken Krugler
Krugle, Inc.
+1 530-210-6378
"Find Code, Find Answers"