Class DeflateComparison

java.lang.Object
gov.usgs.earthquake.distribution.DeflateComparison

public class DeflateComparison extends Object
Deflate an input stream.
  • Constructor Details

    • DeflateComparison

      public DeflateComparison()
  • Method Details

    • deflateStream

      public long deflateStream(int level, InputStream in) throws IOException
      Deflate an input stream.
      Parameters:
      level - deflate level.
      in - input stream to deflate.
      Returns:
      output length in bytes.
      Throws:
      IOException - if IO error occurs
    • transferStream

      public long transferStream(InputStream in) throws IOException
      Transfer an input stream.
      Parameters:
      in - input stream to transfer.
      Returns:
      output length in bytes.
      Throws:
      IOException - if IO error occurs
    • testFile

      public void testFile(File file) throws IllegalArgumentException, IOException
      Test different compression levels and speeds for a file. Reads file into memory to avoid disk io overhead.
      Parameters:
      file - file to test.
      Throws:
      IllegalArgumentException - if illegal arg
      IOException - if IO error occurs
    • testByteArray

      public void testByteArray(String name, byte[] content) throws IOException
      Test different compression levels and speeds for a byte array.
      Parameters:
      name - given name
      content - content to test.
      Throws:
      IllegalArgumentException - if illegal arg
      IOException - if IO error occurs
    • formatResult

      protected void formatResult(long totalBytes, long transferredBytes, long elapsedTime)
      For calculating for properly formatting the results
      Parameters:
      totalBytes - totalBytes
      transferredBytes - Bytes transferred
      elapsedTime - total elapsed time
    • main

      public static void main(String[] args) throws Exception
      A main method for accessing tests using custom files.
      Parameters:
      args - a list of files or directorys to include in compression comparison.
      Throws:
      Exception - if error occurs