Package gov.usgs.earthquake.distribution
Class DeflateComparison
- java.lang.Object
-
- gov.usgs.earthquake.distribution.DeflateComparison
-
public class DeflateComparison extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description DeflateComparison()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longdeflateStream(int level, java.io.InputStream in)Deflate an input stream.protected voidformatResult(long totalBytes, long transferredBytes, long elapsedTime)For calculating for properly formatting the resultsstatic voidmain(java.lang.String[] args)A main method for accessing tests using custom files.voidtestByteArray(java.lang.String name, byte[] content)Test different compression levels and speeds for a byte array.voidtestFile(java.io.File file)Test different compression levels and speeds for a file.longtransferStream(java.io.InputStream in)Transfer an input stream.
-
-
-
Method Detail
-
deflateStream
public long deflateStream(int level, java.io.InputStream in) throws java.io.IOExceptionDeflate 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.IOExceptionTransfer 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.IOExceptionTest 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 argjava.io.IOException- if IO error occurs
-
testByteArray
public void testByteArray(java.lang.String name, byte[] content) throws java.io.IOExceptionTest different compression levels and speeds for a byte array.- Parameters:
name- given namecontent- content to test.- Throws:
java.lang.IllegalArgumentException- if illegal argjava.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- totalBytestransferredBytes- Bytes transferredelapsedTime- total elapsed time
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionA 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
-
-