Statistics gathering

Two main classes are described in this section: StatsInputStream and StatsOutputStream

StatsInputStream

It wraps an InputStream and gathers statistics of the InputStream passed in the constructor. It can be used to:

  • determine the size of the read data
  • the time spent reading from the internal InputStream.
  • the bit rate of the internal stream (the time is counted ignoring time spent from the external program to process the data: it's just the total number of bytes read divided by the number of milliseconds the program is suspended waiting for a read operation).
  • the effective bit rate (it is counted dividing the total amount of data read by the time difference between the first and the last read operation).
InputSream originalStream=....
StatsInputStream srIstream = new StatsInputStream(originalStream);
//performs all the application operation on stream
...
srIstream.close();
long size = srIstream.getSize();
String bitRate = srIstream.getBitRateString();

For further information see the api javadoc

StatsReader

The class StatsInputStream has a counterpart for Character oriented I/O in StatsReader. The usage and the purpose are identical.

For further information see the api javadoc

StatsOutputStream

This class is an OutputStream wrapper. It gathers statistics of the OutputStream passed in the constructor. It can be used to determine the number of bytes written or the time spent writing to the OutputStream.

StatsOutputStream srStream = new StatsOutputStream(originalStream);
//performs all the application operation on stream
...
srStream.close();
long size = srStream.getSize();

For further information see the api javadoc

StatsWriter

The class StatsOutputStream has a counterpart for Character oriented I/O in StatsWriter. The usage and the purpose are identical.

For further information see the api javadoc