private static void test(PrintWriter csvLog, int N, int nbr, int repeat) {
                csvLog.format("\"Algorithm\",\"Sparsity\",\"Bits per int\",\"Compress speed (MiS)\",\"Decompress speed (MiS)\"\n");
                ClusteredDataGenerator cdg = new ClusteredDataGenerator();
                final int max_sparsity = 31 - nbr;
                for (int sparsity = 1; sparsity < max_sparsity; ++sparsity) {
                        System.out.println("# sparsity " + sparsity);
                        System.out.println("# generating random data...");
                        int[][] data = generateTestData(cdg, N, nbr, sparsity);
                        System.out.println("# generating random data... ok.");

                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR128(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR128(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR128(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();
                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new FastPFOR(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();
                        
                        
                        // TODO: support CSV log output.
                        testKamikaze(data, repeat, false);
                        testKamikaze(data, repeat, false);
                        testKamikaze(data, repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new IntegratedComposition(
                                new IntegratedBinaryPacking(),
                                new IntegratedVariableByte()), data, repeat,
                                false);
                        testCodec(csvLog, sparsity, new IntegratedComposition(
                                new IntegratedBinaryPacking(),
                                new IntegratedVariableByte()), data, repeat,
                                false);
                        testCodec(csvLog, sparsity, new IntegratedComposition(
                                new IntegratedBinaryPacking(),
                                new IntegratedVariableByte()), data, repeat,
                                true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new JustCopy(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new JustCopy(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new JustCopy(), data,
                                repeat, true);
                        System.out.println();

                        testByteCodec(csvLog, sparsity, new VariableByte(),
                                data, repeat, false);
                        testByteCodec(csvLog, sparsity, new VariableByte(),
                                data, repeat, false);
                        testByteCodec(csvLog, sparsity, new VariableByte(),
                                data, repeat, true);
                        System.out.println();

                        testByteCodec(csvLog, sparsity,
                                new IntegratedVariableByte(), data, repeat,
                                false);
                        testByteCodec(csvLog, sparsity,
                                new IntegratedVariableByte(), data, repeat,
                                false);
                        testByteCodec(csvLog, sparsity,
                                new IntegratedVariableByte(), data, repeat,
                                true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new BinaryPacking(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new BinaryPacking(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new BinaryPacking(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFD(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFD(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFD(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS9(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS9(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS9(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS16(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS16(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new NewPFDS16(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFD(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFD(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFD(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS9(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS9(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS9(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS16(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS16(), new VariableByte()), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Composition(
                                new OptPFDS16(), new VariableByte()), data,
                                repeat, true);
                        System.out.println();


                        testCodec(csvLog, sparsity, new Simple16(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Simple16(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Simple16(), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new Simple9(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Simple9(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new Simple9(), data,
                                repeat, true);
                        System.out.println();

                        testCodec(csvLog, sparsity, new GroupSimple9(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new GroupSimple9(), data,
                                repeat, false);
                        testCodec(csvLog, sparsity, new GroupSimple9(), data,
                                repeat, true);
                        System.out.println();

                        {
                                IntegerCODEC c = new Composition(
                                        new XorBinaryPacking(),
                                        new VariableByte());
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        false);
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        false);
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        true);
                                System.out.println();
                        }

                        {
                                IntegerCODEC c = new Composition(
                                        new DeltaZigzagBinaryPacking(),
                                        new DeltaZigzagVariableByte());
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        false);
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        false);
                                testCodec(csvLog, sparsity, c, data, repeat,
                                        true);
                                System.out.println();
                        }

                }
        }
private static void test ( PrintWriter csvLog , int N , int nbr , int repeat ) { csvLog . format ( "\"Algorithm\",\"Sparsity\",\"Bits per int\",\"Compress speed (MiS)\",\"Decompress speed (MiS)\"\n" ) ; ClusteredDataGenerator cdg = new ClusteredDataGenerator ( ) ; final int max_sparsity = 31 - nbr ; for ( int sparsity = 1 ; sparsity < max_sparsity ; ++ sparsity ) { System . out . println ( "# sparsity " + sparsity ) ; System . out . println ( "# generating random data..." ) ; int [ ] [ ] data = generateTestData ( cdg , N , nbr , sparsity ) ; System . out . println ( "# generating random data... ok." ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR128 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR128 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR128 ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new FastPFOR ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testKamikaze ( data , repeat , false ) ; testKamikaze ( data , repeat , false ) ; testKamikaze ( data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new IntegratedComposition ( new IntegratedBinaryPacking ( ) , new IntegratedVariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new IntegratedComposition ( new IntegratedBinaryPacking ( ) , new IntegratedVariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new IntegratedComposition ( new IntegratedBinaryPacking ( ) , new IntegratedVariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new JustCopy ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new JustCopy ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new JustCopy ( ) , data , repeat , true ) ; System . out . println ( ) ; testByteCodec ( csvLog , sparsity , new VariableByte ( ) , data , repeat , false ) ; testByteCodec ( csvLog , sparsity , new VariableByte ( ) , data , repeat , false ) ; testByteCodec ( csvLog , sparsity , new VariableByte ( ) , data , repeat , true ) ; System . out . println ( ) ; testByteCodec ( csvLog , sparsity , new IntegratedVariableByte ( ) , data , repeat , false ) ; testByteCodec ( csvLog , sparsity , new IntegratedVariableByte ( ) , data , repeat , false ) ; testByteCodec ( csvLog , sparsity , new IntegratedVariableByte ( ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new BinaryPacking ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new BinaryPacking ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new BinaryPacking ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFD ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFD ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFD ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new NewPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFD ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFD ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFD ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS9 ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Composition ( new OptPFDS16 ( ) , new VariableByte ( ) ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Simple16 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Simple16 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Simple16 ( ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new Simple9 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Simple9 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new Simple9 ( ) , data , repeat , true ) ; System . out . println ( ) ; testCodec ( csvLog , sparsity , new GroupSimple9 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new GroupSimple9 ( ) , data , repeat , false ) ; testCodec ( csvLog , sparsity , new GroupSimple9 ( ) , data , repeat , true ) ; System . out . println ( ) ; { IntegerCODEC c = new Composition ( new XorBinaryPacking ( ) , new VariableByte ( ) ) ; testCodec ( csvLog , sparsity , c , data , repeat , false ) ; testCodec ( csvLog , sparsity , c , data , repeat , false ) ; testCodec ( csvLog , sparsity , c , data , repeat , true ) ; System . out . println ( ) ; } { IntegerCODEC c = new Composition ( new DeltaZigzagBinaryPacking ( ) , new DeltaZigzagVariableByte ( ) ) ; testCodec ( csvLog , sparsity , c , data , repeat , false ) ; testCodec ( csvLog , sparsity , c , data , repeat , false ) ; testCodec ( csvLog , sparsity , c , data , repeat , true ) ; System . out . println ( ) ; } } }
Generates data and calls other tests.

@param csvLog
Writer for CSV log.
@param N
How many input arrays to generate
@param nbr
how big (in log2) should the arrays be
@param repeat
How many times should we repeat tests.