Package dclong.util

Examples of dclong.util.Timer


import dclong.util.Timer;

public class TestTimer {
  public static void main(String[] args) throws InterruptedException{
    Timer timer = new Timer();
    timer.start();
    Thread.sleep(1000);
    timer.stop();
    timer.printSeconds("sleeping");
  }
View Full Code Here


import dclong.util.Timer;

public class TestCombination {
  public static void main(String[] args){
    Timer timer = new Timer();
    Combination comb = new Combination(6,3);
    timer.start();
    dclong.io.Console.print(comb.nextCombination());
    System.out.print("\n");
    dclong.io.Console.print(comb.nextCombination());
    System.out.print("\n");
    System.out.println("---------------------");
    int[][] cs = comb.getCombinations(comb.getTotal().intValue());
    timer.stop();
    int[][] cs2 = new int[cs.length/2][cs[0].length*2];
    for(int i=0; i<cs2.length; ++i){
      for(int j=0; j<cs2[0].length/2; ++j){
        cs2[i][j] = cs[i][j];
      }
      for(int j=cs2[0].length/2; j<cs2[0].length; ++j){
        cs2[i][j] = cs[cs.length-1-i][j-cs2[0].length/2];
      }
    }
    dclong.io.Console.print(cs2);
    timer.printSeconds("generating combinations");
  }
View Full Code Here

    double[][] data = BinaryReader.readDouble(inputFile, numberOfTests, sizeOfEachDataSet);
    int sequentialTerminationCriteria = 10;
    int numberOfPermutations = 1000 - 1;
    int numberOfReps = 1000;
    //-----------------------------------------------
    Timer timer = new Timer();
    timer.start();
    SPTsRep sptRep = new SPTsRep(rng,cs,data,sizeOfFirstGroup,
        sequentialTerminationCriteria,numberOfPermutations,numberOfReps);
    sptRep.run();
    sptRep.save(outputFile);
    timer.stop();
    System.out.println("The time used is " + timer.getElapsedTime()/1000d + " seconds.");
  }
View Full Code Here

    int sequentialTerminationCriteria = 10;
    int numberOfPermutations = 1000;
    //-------------------------------------------------
    SPTsImpl spt = new SPTsImpl(rng,cs,data,sizeOfFirstGroup,
        sequentialTerminationCriteria,numberOfPermutations);
    Timer timer = new Timer();
    timer.start();
    spt.run();
    spt.saveOutput(outputFile);
    timer.stop();
    System.out.println("Time used is: "+timer.getElapsedTime()/1000d);
  }
View Full Code Here

    String outputFile = "D:\\Dropbox\\Research\\Nettleton\\SPT\\Mean\\test-dependent\\testing-data-out-runnable-"+index+".bin";
    double[][] data = BinaryReader.readDouble(inputFile, numberOfTests, sizeOfEachDataSet);
    int[][] randomIndexOfCombinations = generateRandomIndexOfCombinations(rng,numberOfTests,numberOfPermutations,upperBound);
    SPTsRunnable spt = new SPTsRunnable(cs,data,randomIndexOfCombinations,
        sizeOfFirstGroup,sequentialTerminationCriteria,output,simulationIndex);
    Timer timer = new Timer();
    timer.start();
    spt.run();
    timer.stop();
    saveOutput(output,outputFile);
    System.out.println("The time used is :"+timer.getElapsedTime()/1000d+" seconds.");
  }
View Full Code Here

public class TestSPTsSimulation {
  public static void main(String[] args) throws IOException {
    RandomGenerator rg = new Well44497b(31);
    RandomDataImpl rng = new RandomDataImpl(rg);
    // warm up RNG to avoid overlap of the Table-2 job
    Timer timer = new Timer();
    int upperBound = Combination.choose(26, 5).intValue() - 1;
    for (int i = 0; i < 130000000; ++i) {
      for(int j=0; j<100; ++j){
        rng.nextInt(0, upperBound);
      }
    }
    timer.stop();
    System.out.println("Warm-up is done. The time used is " + timer.getElapsedTime()/60000d + " minutes.");
    // -------------------------------------------------------------
    int numberOfTests = 10000;
    int sizeOfFirstGroup = 8;
    int sizeOfSecondGroup = 8;
    int sequentialTerminationCriteria = 10;
    int numberOfPermutations = 1000 - 1;
    int numberOfSimulations = 1000;
    // ---------- Table 3 ----------------------------
    int numberOfTrueNulls = 7500;
    // -----------------------------
    int lambda = 1;
    SPTsSimulation spt = new SPTsSimulation(rng, numberOfTests,
        numberOfTrueNulls, lambda, sizeOfFirstGroup, sizeOfSecondGroup,
        sequentialTerminationCriteria, numberOfPermutations,
        numberOfSimulations);
    String outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ---------------------------------
    lambda = 2;
    spt.setLambda(lambda);
    outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ----------------------------------
    lambda = 3;
    spt.setLambda(lambda);
    outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ----------------------------------
    numberOfTrueNulls = 9000;
    spt.setNumberOfTrueNulls(numberOfTrueNulls);
    // -----------------------
    lambda = 1;
    spt.setLambda(lambda);
    outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ---------------------------------
    lambda = 2;
    spt.setLambda(lambda);
    outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------
    lambda = 3;
    spt.setLambda(lambda);
    outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    timer.start();
    spt.parSimulateIndependent(outputFile);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // //////////////////////////////////////////////////////////////////////////////
    // ------------------------ Table 4 ------------------------------
    String inputFile = "/home/adu/research/nettleton/spt/mean/jdata/data-base.bin";
    String falseNullsFile;
    double[][] baseData = BinaryReader.readDouble(inputFile, 10000, 21);
    double[] sds = standardDeviations(baseData);
    // ---------------------------------------------------------------
    numberOfTrueNulls = 7500;
    spt.setNumberOfTrueNulls(numberOfTrueNulls);
    // ------------------------------------------
    lambda = 1;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ------------------------------------------
    lambda = 2;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------
    lambda = 3;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------------------------
    numberOfTrueNulls = 9000;
    spt.setNumberOfTrueNulls(numberOfTrueNulls);
    // ---------------------------------------------
    lambda = 1;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ------------------------------------------
    lambda = 2;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------
    lambda = 3;
    spt.setLambda(lambda);
    outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
    falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
        + ".bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // /////////////////////////////////////////////////////////////////////////
    // ------------------ more dependent simulation
    // --------------------------
    numberOfTrueNulls = 7500;
    spt.setNumberOfTrueNulls(numberOfTrueNulls);
    lambda = 2;
    spt.setLambda(lambda);
    // ------------------------------------------------
    sequentialTerminationCriteria = 10;
    spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
    // ---------------------------------
    numberOfPermutations = 5000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ---------------------------------
    numberOfPermutations = 10000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ---------------------------------------------------------------
    sequentialTerminationCriteria = 50;
    spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
    // -----------------------------------------------------------------
    numberOfPermutations = 1000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------------------------
    numberOfPermutations = 5000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------------------------
    numberOfPermutations = 10000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // ------------------------------------------------------------------
    sequentialTerminationCriteria = 100;
    spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
    // -----------------------------------------------------------------
    numberOfPermutations = 1000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------------------------
    numberOfPermutations = 5000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
    // -----------------------------------------------------------------
    numberOfPermutations = 10000 - 1;
    spt.setNumberOfPermutations(numberOfPermutations);
    outputFile = "d-" + numberOfPermutations + "-"
        + sequentialTerminationCriteria + "-7500-2.bin";
    falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
    timer.start();
    spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
//    spt.simulateIndependent(outputFile);
    timer.stop();
    System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
  }
View Full Code Here

*/
public class TestSpeed {
  public static void main(String[] args) {
    RandomGenerator rg = new Well44497b();
    RandomDataImpl rng = new RandomDataImpl(rg);
    Timer timer = new Timer();
    timer.begin();
    final int MAX_THREADS = Runtime.getRuntime().availableProcessors();
    ExecutorService pool = Executors.newFixedThreadPool(MAX_THREADS);
    for (int i = 0; i < 10000; i++) {
      pool.execute(new RandomPermutationRunnable(rng, 2869, 330));
    }
    pool.shutdown();
    while (!pool.isTerminated()) {
      try {
        pool.awaitTermination(1000, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    timer.end();
    timer.printSeconds("generating random numbers in parallel");
    timer.begin();
    for (int i = 0; i < 10000; i++) {
//      rng.nextPermutation(2869, 330);
      for (int j = 0; j < 100000; j++) {
        Math.pow(j, 8);
      }
    }
    timer.end();
    timer.printSeconds("generating random numbers in serial");
  }
View Full Code Here

public class TestRNGSpeed {
  public static void main(String[] args){
    //CommonMath
    RandomGenerator rg = new Well44497b(29);
    RandomDataImpl rng = new RandomDataImpl(rg);
    Timer timer = new Timer();
    timer.start();
    for(long i=0; i<130000000; ++i){
//      rng.nextPermutation(16, 8);
//      rng.nextGaussian(0, 1);
      rng.nextInt(0, 65779);
    }
    timer.stop();
    timer.printSeconds("generating random numbers");
  }
View Full Code Here

TOP

Related Classes of dclong.util.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.