/*
 * SUDA2: An implementation of the SUDA2 algorithm for Java
 * Copyright 2017 Fabian Prasser
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.linearbits.test;

import java.io.IOException;

import de.linearbits.suda2.SUDA2;
import de.linearbits.suda2.SUDA2IntSetBits;
import de.linearbits.suda2.SUDA2IntSetHash;
import de.linearbits.suda2.SUDA2Result;

/**
 * Test based on survey data data
 * 
 * @author Fabian Prasser
 */
public class Test9 extends AbstractTest{

    /**
     * Main entry point
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
       
        // As array
        
        
        //THATSIT!!! int[][] data = getData("data/test3.csv"); // Whatever
        
        
        // int[][] data = getData("data/test2.csv"); // Whatever
        // int[][] data = getData("data/test4.csv"); // FARS
         int[][] data = getData("data/test5.csv"); // IHIS
        //int[][] data = getData("data/test6.csv"); // SS13ACS -> SDCM: 1.67 hours, This: 21.06 hours
        // int[][] data = getData("data/test7.csv"); // CUP
        
        System.out.println("Num. records: " + data.length);
        
        // Process
        int REPETITIONS = 1;
        long time = System.currentTimeMillis();
        SUDA2Result result1 = null;
        for (int i=0; i<REPETITIONS; i++) {
            result1 = new SUDA2(data).getKeyStatistics(0, true);
        }
        time = (long)((System.currentTimeMillis() - time) / (double)REPETITIONS);
        System.out.println("Time: " + time);
        System.out.println(result1);
    }
}

@@ -745,136 +745,8 @@
 DA2;
-%0Aimport de.linearbits.suda2.SUDA2IntSetBits;%0Aimport de.linearbits.suda2.SUDA2IntSetHash;%0Aimport de.linearbits.suda2.SUDA2Result;
 %0A%0A/*
@@ -1048,62 +1048,51 @@
     
-%0A        %0A        //THATSIT!!! int%5B%5D%5B%5D data = getData(
+String%5B%5D files = new String%5B%5D%7B%0A            
 %22dat
@@ -1101,28 +1101,26 @@
 test
-3
 .csv%22
-); // Whatever
+,    // Adult
 %0A   
@@ -1128,52 +1128,56 @@
     
-%0A
     
-    %0A        // int%5B%5D%5B%5D data = getData(
+%22data/test2.csv%22,   // Whatever%0A            
 %22dat
@@ -1186,16 +1186,17 @@
 test
-2
+3
 .csv%22
-);
+,  
  // 
@@ -1216,34 +1216,12 @@
     
-// int%5B%5D%5B%5D data = getData(
+    
 %22dat
@@ -1228,26 +1228,27 @@
 a/test4.csv%22
-);
+,  
  // FARS%0A   
@@ -1253,39 +1253,58 @@
         
-int%5B%5D%5B%5D data = getData(
+   %22data/test7.csv%22,   // CUP%0A            
 %22data/te
@@ -1307,26 +1307,27 @@
 a/test5.csv%22
-);
+,  
  // IHIS%0A   
@@ -1335,33 +1335,12 @@
     
-//int%5B%5D%5B%5D data = getData(
+    
 %22dat
@@ -1347,26 +1347,27 @@
 a/test6.csv%22
-);
+   
  // SS13ACS 
@@ -1369,56 +1369,75 @@
 3ACS
- -%3E SDCM: 1.67 hours, This: 21.06 hours%0A
+%0A        %7D;%0A        %0A        for (String file : files) %7B%0A  
         
 // i
@@ -1432,18 +1432,17 @@
         
-//
+ 
  int%5B%5D%5B%5D
@@ -1446,16 +1446,19 @@
 %5D%5B%5D data
+set
  = getDa
@@ -1464,83 +1464,75 @@
 ata(
-%22data/test7.csv%22); // CUP%0A        %0A        System.out.println(%22Num. records
+file);%0A            System.out.println(%22Dataset: %22 + file + %22 length
 : %22 
@@ -1537,16 +1537,19 @@
 %22 + data
+set
 .length)
@@ -1554,29 +1554,24 @@
 h);%0A        
-%0A    
     // Proce
@@ -1581,16 +1581,20 @@
         
+ 
+   
 int REPE
@@ -1607,11 +1607,15 @@
 S = 
-1
+5
 ;%0A
+    
     
@@ -1666,40 +1666,8 @@
     
-    SUDA2Result result1 = null;%0A
     
@@ -1722,17 +1722,68 @@
     
-result1 =
+    long time2 = System.currentTimeMillis();%0A               
  new
@@ -1793,16 +1793,19 @@
 DA2(data
+set
 ).getKey
@@ -1833,18 +1833,111 @@
         
-%7D%0A
+        System.out.println(%22 Run: %22 + (System.currentTimeMillis() - time2));%0A            %7D%0A    
         
@@ -2010,32 +2010,36 @@
 TIONS);%0A        
+    
 System.out.print
@@ -2042,17 +2042,28 @@
 rintln(%22
-T
+ - Average t
 ime: %22 +
@@ -2082,41 +2082,14 @@
     
-System.out.println(result1);
+%7D
 %0A    %7D%0A%7D
 %0A
@@ -2087,9 +2087,8 @@
 %0A    %7D%0A%7D
-%0A

Restructure tests