public static void testKamikaze(int[][] data, int repeat,
                boolean verbose) {
                DecimalFormat df = new DecimalFormat("0.00");
                DecimalFormat dfspeed = new DecimalFormat("0");
                if (verbose)
                        System.out.println("# kamikaze PForDelta");
                if (verbose)
                        System.out
                                .println("# bits per int, compress speed (mis), decompression speed (mis) ");
                long bef, aft;
                String line = "";
                int N = data.length;
                int totalsize = 0;
                int maxlength = 0;
                for (int k = 0; k < N; ++k) {
                        totalsize += data[k].length;
                        if (data[k].length > maxlength)
                                maxlength = data[k].length;
                }
                int[] buffer = new int[maxlength + 1024];
                /*
                 * 4x + 1024 to account for the possibility of some negative
                 * compression
                 */
                int size = 0;
                int comptime = 0;
                long decomptime = 0;
                for (int r = 0; r < repeat; ++r) {
                        size = 0;
                        for (int k = 0; k < N; ++k) {
                                int outpos = 0;
                                int[] backupdata = Arrays.copyOf(data[k],
                                        data[k].length);
                                //
                                bef = System.nanoTime() / 1000;
                                Delta.delta(backupdata);
                                ArrayList<int[]> dataout = new ArrayList<int[]>(
                                        data[k].length / 128);
                                for (int K = 0; K < data[k].length; K += 128) {
                                        final int[] compressedbuf = PForDelta
                                                .compressOneBlockOpt(Arrays
                                                        .copyOfRange(
                                                                backupdata, K,
                                                                K + 128), 128);
                                        dataout.add(compressedbuf);
                                        outpos += compressedbuf.length;
                                }
                                aft = System.nanoTime() / 1000;
                                //
                                comptime += aft - bef;
                                final int thiscompsize = outpos;
                                size += thiscompsize;
                                //
                                bef = System.nanoTime() / 1000;
                                ArrayList<int[]> datauncomp = new ArrayList<int[]>(
                                        dataout.size());
                                int deltaoffset = 0;

                                for (int[] compbuf : dataout) {
                                        int[] tmpbuf = new int[128];
                                        PForDelta.decompressOneBlock(tmpbuf,
                                                compbuf, 128);
                                        tmpbuf[0] += deltaoffset;
                                        Delta.fastinverseDelta(tmpbuf);
                                        deltaoffset = tmpbuf[127];
                                        datauncomp.add(tmpbuf);
                                }
                                aft = System.nanoTime() / 1000;
                                //
                                decomptime += aft - bef;
                                if (datauncomp.size() * 128 != data[k].length)
                                        throw new RuntimeException(
                                                "we have a bug (diff length) "
                                                        + " expected "
                                                        + data[k].length
                                                        + " got "
                                                        + datauncomp.size()
                                                        * 128);
                                for (int m = 0; m < data[k].length; ++m)
                                        if (datauncomp.get(m / 128)[m % 128] != data[k][m]) {
                                                throw new RuntimeException(
                                                        "we have a bug (actual difference), expected "
                                                                + data[k][m]
                                                                + " found "
                                                                + buffer[m]
                                                                + " at " + m);
                                        }

                        }
                }

                line += "\t" + df.format(size * 32.0 / totalsize);
                line += "\t" + dfspeed.format(totalsize * repeat / (comptime));
                line += "\t"
                        + dfspeed.format(totalsize * repeat / (decomptime));
                if (verbose)
                        System.out.println(line);
        }
public static void testKamikaze ( int [ ] [ ] data , int repeat , boolean verbose ) { DecimalFormat df = new DecimalFormat ( "0.00" ) ; DecimalFormat dfspeed = new DecimalFormat ( "0" ) ; if ( verbose ) System . out . println ( "# kamikaze PForDelta" ) ; if ( verbose ) System . out . println ( "# bits per int, compress speed (mis), decompression speed (mis) " ) ; long bef , aft ; String line = "" ; int N = data . length ; int totalsize = 0 ; int maxlength = 0 ; for ( int k = 0 ; k < N ; ++ k ) { totalsize += data [ k ] . length ; if ( data [ k ] . length > maxlength ) maxlength = data [ k ] . length ; } int [ ] buffer = new int [ maxlength + 1024 ] ; int size = 0 ; int comptime = 0 ; long decomptime = 0 ; for ( int r = 0 ; r < repeat ; ++ r ) { size = 0 ; for ( int k = 0 ; k < N ; ++ k ) { int outpos = 0 ; int [ ] backupdata = Arrays . copyOf ( data [ k ] , data [ k ] . length ) ; bef = System . nanoTime ( ) / 1000 ; Delta . delta ( backupdata ) ; ArrayList < int [ ] > dataout = new ArrayList < int [ ] > ( data [ k ] . length / 128 ) ; for ( int K = 0 ; K < data [ k ] . length ; K += 128 ) { final int [ ] compressedbuf = PForDelta . compressOneBlockOpt ( Arrays . copyOfRange ( backupdata , K , K + 128 ) , 128 ) ; dataout . add ( compressedbuf ) ; outpos += compressedbuf . length ; } aft = System . nanoTime ( ) / 1000 ; comptime += aft - bef ; final int thiscompsize = outpos ; size += thiscompsize ; bef = System . nanoTime ( ) / 1000 ; ArrayList < int [ ] > datauncomp = new ArrayList < int [ ] > ( dataout . size ( ) ) ; int deltaoffset = 0 ; for ( int [ ] compbuf : dataout ) { int [ ] tmpbuf = new int [ 128 ] ; PForDelta . decompressOneBlock ( tmpbuf , compbuf , 128 ) ; tmpbuf [ 0 ] += deltaoffset ; Delta . fastinverseDelta ( tmpbuf ) ; deltaoffset = tmpbuf [ 127 ] ; datauncomp . add ( tmpbuf ) ; } aft = System . nanoTime ( ) / 1000 ; decomptime += aft - bef ; if ( datauncomp . size ( ) * 128 != data [ k ] . length ) throw new RuntimeException ( "we have a bug (diff length) " + " expected " + data [ k ] . length + " got " + datauncomp . size ( ) * 128 ) ; for ( int m = 0 ; m < data [ k ] . length ; ++ m ) if ( datauncomp . get ( m / 128 ) [ m % 128 ] != data [ k ] [ m ] ) { throw new RuntimeException ( "we have a bug (actual difference), expected " + data [ k ] [ m ] + " found " + buffer [ m ] + " at " + m ) ; } } } line += "\t" + df . format ( size * 32.0 / totalsize ) ; line += "\t" + dfspeed . format ( totalsize * repeat / ( comptime ) ) ; line += "\t" + dfspeed . format ( totalsize * repeat / ( decomptime ) ) ; if ( verbose ) System . out . println ( line ) ; }
Standard test for the Kamikaze library

@param data
input data
@param repeat
how many times to repeat
@param verbose
whether to output data on screen