|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.ngram.compression.Test
public final class Test
Runs test suite for arithmetic coding and decoding with all of th esupplied
compression models from main(java.lang.String[])
. Behavior is specified with
the following arguments.
-f FileName:
Test specified file.-s Integer:
Sized tests up to specified number of bytes.-g:
Run small tests.String:
Test specified string.-c Directory:
Test calgary corpus found in specified directory.-x Directory:
Test xml corpus found in specified directory.The Calgary corpus can be downloaded from:
ftp://ftp.cpsc.ucalgary.ca/pub/projects/text.compression.corpus .
Because of the use of statics, only a single test should be run per virtual machine.
ArithCodeModel
,
ArithCodeInputStream
,
ArithCodeOutputStream
,
AdaptiveUnigramModel
,
UniformModel
,
PPMModel
Field Summary | |
---|---|
private static TestSet |
_testSet
Creates the test set to use for the tests. |
Constructor Summary | |
---|---|
private |
Test()
Hide unused constructor. |
Method Summary | |
---|---|
private static java.lang.String |
compressionRateString(int numBytesIn,
int numBytesOut)
Returns a string representation of the compression rate indicated by the specified number of original bytes and compressed bytes. |
(package private) static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
Read all of the input from the given input stream and write it to the given output stream. |
(package private) static long |
elapsed(long start)
Return elapsed time since specified time in milliseconds (1/1000 second). |
private static java.lang.String |
intToString(int n,
int minLength)
Convert an integer to a string, padding with spaces in the front to provide a result of the specified minimum length. |
static void |
main(java.lang.String[] args)
Runs test suite as specified by arguments. |
private static byte |
nextByteRange(java.util.Random r,
int low,
int high)
Generates the next random byte between the specified low and high bytes inclusive, using the specified randomizer. |
private static void |
nextRandomAlphaNum(byte[] bs,
java.util.Random r)
Fills the specified byte array with random alphanumeric characters generated by the specified randomizer. |
private static byte |
nextRandomAlphaNum(java.util.Random r)
Returns next random alphabetic or numeric byte as determined by the specified randomizer. |
private static java.lang.String |
speedString(int numBytes,
long numMillis)
Returns a string representation of the speed of compression indicated by the specified number of original bytes and time in milliseconds. |
private static boolean |
test(byte[] bytes)
Tests compression/decompression of a given sequence of bytes. |
private static boolean |
test(java.io.File file)
Tests compression/decompression of a given file. |
private static boolean |
test(java.lang.String text)
Tests compression/decompression of a given string. |
private static boolean |
testBytes(byte[] bytes)
Tests given sequence of bytes against various models. |
private static boolean |
testBytes(byte[] bytes,
ArithCodeModel modelIn,
ArithCodeModel modelOut,
java.lang.String name)
Tests specified sequence of bytes with specified models for input and output, and specified name. |
private static boolean |
testBytesGZIP(byte[] bytes,
java.lang.String name)
Tests specified sequence of bytes with Zip compression and specified name. |
private static void |
testCalgary(java.lang.String path)
Runs a test on the Calgary corpus. |
private static void |
testFixed()
Fixed test suite. |
private static boolean |
testPPMBytes(byte[] bytes,
int order)
Run a test of PPM on the specified bytes using a model of the specified order. |
private static void |
testSize(int size)
Runs tests from 1 to give size, increasing size by a factor of two at each step. |
private static void |
testXML(java.lang.String path)
Runs a test on James Cheney's XML corpus. |
(package private) static java.lang.String |
timeToSeconds(long t)
Convert specified time in milliseconds to a string in seconds. |
private static java.lang.String |
trim(java.lang.String in)
Truncates string to printable length, appending epenthetic dots if it is truncated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static TestSet _testSet
Constructor Detail |
---|
private Test()
Method Detail |
---|
public static void main(java.lang.String[] args) throws java.io.IOException
-f FileName:
Test specified file.-s Integer:
Sized tests up to specified number of bytes.-g:
Run small tests.String:
Test specified string.-c Directory:
Test calgary corpus found in specified directory.-x Directory:
Test James Cheney's XML corpus found in specified directory.
args
- Parameters in fixed order.
java.io.IOException
- If there is an underlying I/O exception during compression/decompression.static void copyStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- Input stream from which to read.out
- Output stream to which to write.
java.io.IOException
- If there is an exception reading or writing on the given streams.static long elapsed(long start)
start
- Time from which to measure.
static java.lang.String timeToSeconds(long t)
t
- Time to convert to a string.
private static void testSize(int size) throws java.io.IOException
size
- Maximum size up to which to test.
java.io.IOException
- If there is an underlying I/O exception during compression/decompression.private static void testFixed() throws java.io.IOException
java.io.IOException
- If there is an underlying I/O exception during compression/decompression.private static void testXML(java.lang.String path) throws java.io.IOException
path
- Name of directory in which to find the Calgary corpus.
java.io.IOException
- If there is an underlying I/O exception during compression/decompression.private static void testCalgary(java.lang.String path) throws java.io.IOException
path
- Name of directory in which to find the Calgary corpus.
java.io.IOException
- If there is an underlying I/O exception during compression/decompression.private static boolean test(java.io.File file) throws java.io.IOException
file
- File to test.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static boolean test(java.lang.String text) throws java.io.IOException
String.getBytes(int, int, byte[], int)
.
text
- String to test for compression/decompression.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static boolean test(byte[] bytes) throws java.io.IOException
bytes
- Bytes to test for compression/decompression.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static boolean testPPMBytes(byte[] bytes, int order) throws java.io.IOException
bytes
- Bytes to test.order
- Order of PPM model to use.
true
if the test is successful.
java.io.IOException
private static boolean testBytes(byte[] bytes) throws java.io.IOException
bytes
- Bytes to test for compression/decompression.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static boolean testBytes(byte[] bytes, ArithCodeModel modelIn, ArithCodeModel modelOut, java.lang.String name) throws java.io.IOException
bytes
- Bytest to test.modelIn
- Model to use for encoding.modelOut
- Model to use for decoding.name
- Name ot use for display.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static boolean testBytesGZIP(byte[] bytes, java.lang.String name) throws java.io.IOException
bytes
- Bytest to test.modelIn
- Model to use for encoding.modelOut
- Model to use for decoding.name
- Name ot use for display.
true
if the test succeeds.
java.io.IOException
- If there is an underlying I/O exception.private static java.lang.String compressionRateString(int numBytesIn, int numBytesOut)
numOriginalBytes
- Number of uncompressed bytes.numCompressedBytes
- Number of bytes in the compressed file.
private static java.lang.String intToString(int n, int minLength)
n
- Integer to convert to string.minLength
- Minimum length of result.
private static java.lang.String speedString(int numBytes, long numMillis)
numBytes
- Number of uncompressed bytes.numMillis
- Number of milliseconds.
private static java.lang.String trim(java.lang.String in)
in
- String to truncate.
private static void nextRandomAlphaNum(byte[] bs, java.util.Random r)
bs
- Byte array to fill.r
- Randomizer.private static byte nextByteRange(java.util.Random r, int low, int high)
r
- Randomizer.low
- Low end of byte range, inclusive.high
- High end of byte range, inclusive.
private static byte nextRandomAlphaNum(java.util.Random r)
r
- Randomizer.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |