// Path: src/main/java/org/rascalmpl/interpreter/utils/Timing.java
// public final class Timing {
// 
//   private long start;
// 
//   public Timing() {
//     super();
//   }
// 
//   public void start() {
//     start = getCpuTime();
//   }
// 
//   public long duration() {
//     long now = getCpuTime();
//     long diff = now - start;
//     start = now;
//     return diff;
//   }
// 
//   public static long getCpuTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         bean.getCurrentThreadCpuTime() : 0L;
//   }
// 
//   /**
//    * Get user time in nanoseconds.
//    */
//   public static long getUserTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         bean.getCurrentThreadUserTime() : 0L;
//   }
// 
//   /**
//    * Get system time in nanoseconds.
//    */
//   public static long getSystemTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         (bean.getCurrentThreadCpuTime() - bean.getCurrentThreadUserTime()) : 0L;
//   }
// }
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final String DATA_SET_SINGLE_FILE_NAME = "data/single.bin";
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final boolean LOG_BINARY_RESULTS = false;
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final boolean LOG_TEXTUAL_RESULTS = false;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import io.usethesource.capsule.Set;
import io.usethesource.capsule.Set.Transient;
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.IMap;
import io.usethesource.vallang.IMapWriter;
import io.usethesource.vallang.ISet;
import io.usethesource.vallang.ISetWriter;
import io.usethesource.vallang.ITuple;
import io.usethesource.vallang.IValue;
import io.usethesource.vallang.IValueFactory;
import io.usethesource.vallang.io.StandardTextWriter;
import io.usethesource.vallang.io.old.BinaryValueReader;
import io.usethesource.vallang.io.old.BinaryValueWriter;
import org.rascalmpl.interpreter.utils.Timing;
import static dom.AllDominatorsRunner.CURRENT_DATA_SET_FILE_NAME;
import static dom.AllDominatorsRunner.DATA_SET_SINGLE_FILE_NAME;
import static dom.AllDominatorsRunner.LOG_BINARY_RESULTS;
import static dom.AllDominatorsRunner.LOG_TEXTUAL_RESULTS;

      // if (!newDom.done().getValueType().getElementType().isAbstractData()) {
      // System.err.println("not good");
      // }
      dom = newDom.done();
    }

    return dom;
  }

  public static void main(String[] args) throws FileNotFoundException, IOException {
    testAll(io.usethesource.vallang.impl.persistent.ValueFactory.getInstance());
    testAll(io.usethesource.vallang.impl.fast.ValueFactory.getInstance());
  }

  public static IMap testOne(IValueFactory vf) throws IOException, FileNotFoundException {
    ISet data =
        (ISet) new BinaryValueReader().read(vf, new FileInputStream(DATA_SET_SINGLE_FILE_NAME));

    long before = Timing.getCpuTime();
    IMap pdbResults = new DominatorsPDB(vf).jDominators(data);

    System.err.println(vf.toString() + "\nDuration: "
        + ((Timing.getCpuTime() - before) / 1000000000) + " seconds\n");

    if (LOG_BINARY_RESULTS) {
      new BinaryValueWriter().write(pdbResults,
          new FileOutputStream("data/dominators-java-" + vf.toString() + "-single.bin"));
    }

// Path: src/main/java/org/rascalmpl/interpreter/utils/Timing.java
// public final class Timing {
// 
//   private long start;
// 
//   public Timing() {
//     super();
//   }
// 
//   public void start() {
//     start = getCpuTime();
//   }
// 
//   public long duration() {
//     long now = getCpuTime();
//     long diff = now - start;
//     start = now;
//     return diff;
//   }
// 
//   public static long getCpuTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         bean.getCurrentThreadCpuTime() : 0L;
//   }
// 
//   /**
//    * Get user time in nanoseconds.
//    */
//   public static long getUserTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         bean.getCurrentThreadUserTime() : 0L;
//   }
// 
//   /**
//    * Get system time in nanoseconds.
//    */
//   public static long getSystemTime() {
//     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
//     return bean.isCurrentThreadCpuTimeSupported() ?
//         (bean.getCurrentThreadCpuTime() - bean.getCurrentThreadUserTime()) : 0L;
//   }
// }
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final String DATA_SET_SINGLE_FILE_NAME = "data/single.bin";
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final boolean LOG_BINARY_RESULTS = false;
// 
// Path: src/main/java/dom/AllDominatorsRunner.java
// public static final boolean LOG_TEXTUAL_RESULTS = false;


// Path: src/main/java/dom/DominatorsPDB.java
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import io.usethesource.capsule.Set;
import io.usethesource.capsule.Set.Transient;
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.IMap;
import io.usethesource.vallang.IMapWriter;
import io.usethesource.vallang.ISet;
import io.usethesource.vallang.ISetWriter;
import io.usethesource.vallang.ITuple;
import io.usethesource.vallang.IValue;
import io.usethesource.vallang.IValueFactory;
import io.usethesource.vallang.io.StandardTextWriter;
import io.usethesource.vallang.io.old.BinaryValueReader;
import io.usethesource.vallang.io.old.BinaryValueWriter;
import org.rascalmpl.interpreter.utils.Timing;
import static dom.AllDominatorsRunner.CURRENT_DATA_SET_FILE_NAME;
import static dom.AllDominatorsRunner.DATA_SET_SINGLE_FILE_NAME;
import static dom.AllDominatorsRunner.LOG_BINARY_RESULTS;
import static dom.AllDominatorsRunner.LOG_TEXTUAL_RESULTS;


      // if (!newDom.done().getValueType().getElementType().isAbstractData()) {
      // System.err.println("not good");
      // }
      dom = newDom.done();
    }

    return dom;
  }

  public static void main(String[] args) throws FileNotFoundException, IOException {
    testAll(io.usethesource.vallang.impl.persistent.ValueFactory.getInstance());
    testAll(io.usethesource.vallang.impl.fast.ValueFactory.getInstance());
  }

  public static IMap testOne(IValueFactory vf) throws IOException, FileNotFoundException {
    ISet data =
        (ISet) new BinaryValueReader().read(vf, new FileInputStream(DATA_SET_SINGLE_FILE_NAME));

    long before = Timing.getCpuTime();
    IMap pdbResults = new DominatorsPDB(vf).jDominators(data);

    System.err.println(vf.toString() + "\nDuration: "
        + ((Timing.getCpuTime() - before) / 1000000000) + " seconds\n");

    if (LOG_BINARY_RESULTS) {
      new BinaryValueWriter().write(pdbResults,
          new FileOutputStream("data/dominators-java-" + vf.toString() + "-single.bin"));
    }

    if (LOG_TEXTUAL_RESULTS) {