Class DeflateComparison


  • public class DeflateComparison
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long deflateStream​(int level, java.io.InputStream in)
      Deflate an input stream.
      protected void formatResult​(long totalBytes, long transferredBytes, long elapsedTime)
      For calculating for properly formatting the results
      static void main​(java.lang.String[] args)
      A main method for accessing tests using custom files.
      void testByteArray​(java.lang.String name, byte[] content)
      Test different compression levels and speeds for a byte array.
      void testFile​(java.io.File file)
      Test different compression levels and speeds for a file.
      long transferStream​(java.io.InputStream in)
      Transfer an input stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DeflateComparison

        public DeflateComparison()
    • Method Detail

      • deflateStream

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

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

        public void testFile​(java.io.File file)
                      throws java.lang.IllegalArgumentException,
                             java.io.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:
        java.lang.IllegalArgumentException - if illegal arg
        java.io.IOException - if IO error occurs
      • testByteArray

        public void testByteArray​(java.lang.String name,
                                  byte[] content)
                           throws java.io.IOException
        Test different compression levels and speeds for a byte array.
        Parameters:
        name - given name
        content - content to test.
        Throws:
        java.lang.IllegalArgumentException - if illegal arg
        java.io.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​(java.lang.String[] args)
                         throws java.lang.Exception
        A main method for accessing tests using custom files.
        Parameters:
        args - a list of files or directorys to include in compression comparison.
        Throws:
        java.lang.Exception - if error occurs