public static void main(String[] args) {
System.out.println("Usage: java [-DDICT=c:/words.txt] org.jvcompress.lzo.Min1Comp");
int[] dict = new int[128*1024];
byte[] in = new byte[IN_LEN];
byte[] out = new byte[OUT_LEN];
MInt outL=new MInt();
// Try zero-filled data
for(int ii=0;ii<10;ii++){
clearDict(dict);
long l1 = System.currentTimeMillis();
int r = MiniLZO.lzo1x_1_compress(in,IN_LEN,out,outL,dict);
long l10 = System.currentTimeMillis();
System.out.println(ii+". Zero Data Compress ret="+r+", out_lenth:"+outL.v +
",comp-millis:"+R(l10-l1,IN_LEN,outL.v)+
", Zero Data Decompressing ..." );
MInt OL=new MInt();
r = MiniLZO.lzo1x_decompress(out,(int)outL.v,in,OL);
long l2 = System.currentTimeMillis();
System.out.println(ii+". Zero Data Got decompressed length:"+OL.v+
", Zero Data checking ... millis:" + R(l2-l10,OL.v,outL.v));
for(int i=0;i<OL.v;i++){
if( in[i]!= 0){
throw new AssertionError(ii+". Zero Data Decompreesed values not matching to Zero @:"+i);
}
}
}
Random ran = new Random();
byte[] in_rand = new byte[IN_LEN];
int[] partial = new int[]{16,32,64,128,192,224,256};
// Then Try random-filled data
for(int j=0;j<partial.length;j++){
int lim=partial[j];
for(int ii=0;ii<10;ii++){
clearDict(dict);
boolean repeatPattern=ii >= 5;
// For first 5 iteration pure Random data, then some repeated chars
fillPartillyRandom(lim, in_rand, ran,repeatPattern);
System.arraycopy(in_rand, 0, in, 0, in_rand.length);
long l1 = System.currentTimeMillis();
outL=new MInt();
int r = MiniLZO.lzo1x_1_compress(in,IN_LEN,out,outL,dict);
long l10 = System.currentTimeMillis();
System.out.println(ii+". Random Data("+lim+"/repeatPattern:"+repeatPattern+") Compress ret="+r+", outL:"+outL.v +
", millis:"+R(l10-l1,IN_LEN,outL.v));
MInt OL=new MInt();
r = MiniLZO.lzo1x_decompress(out,(int)outL.v,in,OL);
long l2 = System.currentTimeMillis();
System.out.println(ii+". Random Data("+lim+"/repeatPattern:"+repeatPattern+")Got decompressed length:"+OL.v+
",millis:"+ R(l2-l10,OL.v,outL.v));
for(int i=0;i<OL.v;i++){
if( in[i]!= in_rand[i]){
throw new AssertionError(ii+". Random Data("+lim+"/repeatPattern:"+repeatPattern+") Decompreesed values not matching to Zero @:"+i);
}
}
}
}
// Then Try some user given data-file
BufferedInputStream fis=null;
try{
String file=System.getProperty("DICT","c:/words.txt");
fis = new BufferedInputStream(new FileInputStream(file));
for(;;){
int read=fis.read(in_rand);
if(read < 0) break;
for(int ii=0;ii<10;ii++){
clearDict(dict);
System.arraycopy(in_rand, 0, in, 0, read);
outL=new MInt();
long l1 = System.currentTimeMillis();
int r = MiniLZO.lzo1x_1_compress(in,read,out,outL,dict);
long l10 = System.currentTimeMillis();
System.out.println(ii+". Dict-File Data("+read+") Compress ret="+r+", outL:"+outL.v +
", millis:"+R(l10-l1,read,outL.v));
MInt OL=new MInt();
r = MiniLZO.lzo1x_decompress(out,(int)outL.v,in,OL);
long l2 = System.currentTimeMillis();
System.out.println(ii+". Dict-File Data("+read+")Got decompressed length:"+OL.v+
", millis:"+R(l2-l10,OL.v,outL.v));
if(OL.v != read){