Package org.jamesii.core.util

Examples of org.jamesii.core.util.StopWatch


   */
  private double runExperiment(Long rngSeed, PerfDBRecorder perfRecorder) {
    if (rngSeed != null) {
      SimSystem.getRNGGenerator().setSeed(rngSeed);
    }
    StopWatch watch = new StopWatch();
    perfRecorder.start();
    watch.start();
    experiment.execute();
    watch.stop();
    perfRecorder.stop();
    elapsedTime = watch.elapsedSeconds();
    return elapsedTime;
  }
View Full Code Here


      double predictedPerformance) {

    List<Double> performances = new ArrayList<>();
    for (Map<String, Object> parameterSetup : setup.getSecondValue()) {
      System.err.println("Executing: " + Strings.dispMap(parameterSetup));
      StopWatch sw = new StopWatch();
      sw.start();
      BaseExperiment exp = new BaseExperiment();
      exp.getFixedModelParameters().putAll(parameterSetup);
      exp.setModelLocation(exploration.getExperiment().getModelLocation());
      exp.setDefaultSimStopTime(defaultSimStopTime);
      exp.execute();
      sw.stop();
      performances.add(sw.elapsedSeconds());
    }

    return new RealWorldSelectorPerformanceEntry(setup.getFirstValue(),
        performances, selGenFactoryName, predictedPerformance);
  }
View Full Code Here

                    new ParameterBlock(UCB2Factory.class.getName()));
            pb.addSubBl(ParallelComputationTaskRunnerFactory.NUM_CORES, 1);
            be.setTaskRunnerFactory(new ParameterizedFactory<TaskRunnerFactory>(
                new AdaptiveTaskRunnerFactory(), pb));

            StopWatch sw = new StopWatch();
            sw.start();
            be.execute();
            sw.stop();
            System.err.println("Execution Time:" + sw.elapsedMilliseconds());
            execTimes.add(sw.elapsedMilliseconds() / 1000.0);
            System.err.println("Execution Times:"
                + Strings.dispIterable(execTimes));
          }
        }
      }
View Full Code Here

  /**
   * Makes this experiment executable again after it has been serialized.
   */
  private void recreate() {
    setExperimentExecutionController(new DefaultExecutionController());
    setOverallRuntimeStopWatch(new StopWatch());
  }
View Full Code Here

     * q.enqueue(new Object(), 8.3); q.enqueue(new Object(), 22.3);
     */

    int distrib = 3;

    StopWatch sw = new StopWatch();

    sw.start();

    for (int i = 0; i < 100000; i++) {

      double rand = Math.random();

      switch (distrib) {

      case 0:
        // Exponential
        q.enqueue(getObj(), -Math.log(rand));
        break;

      case 1:
        // Uniform 0.0 - 2.0
        q.enqueue(getObj(), 2 * rand);
        break;

      case 2:
        // Biased 0.9 - 1.1
        q.enqueue(getObj(), 0.9 + 0.2 * rand);
        break;

      case 3: {
        // Biomodal

        if (rand < 0.1) {
          q.enqueue(getObj(), 0.95238 + 9.5238 * rand);
        } else {
          q.enqueue(getObj(), 0.95238 + rand);
        }
        break;
      }

      case 4:
        // Triangular
        q.enqueue(getObj(), 1.5 * Math.pow(rand, 0.5));
      }
    }

    sw.stop();
    System.out.println("Enqueing took " + sw.elapsedSeconds() + " seconds ");

    /*
     * System.out.println("The event queue (intially filled)");
     * q.print(System.out);
     */
 
View Full Code Here

  /**
   * Test to check the AbortionCriterion (@link WallClockTimeAbort).
   */
  public void testWallClock() {
    StopWatch watch = new StopWatch();
    gaps.setFitness(new SimpleFitness());
    gaps.setNumIndividuals(NUM_OF_IND);
    watch.start();
    gaps.setAbortCriterion(new WallClockTimeAbort(MILLISECONDS));
    gaps.portfolio(problemDescription);
    watch.stop();
    assertEquals(
        "Test should run " + MILLISECONDS + " but runs "
            + watch.elapsedMilliseconds() + ".", MILLISECONDS,
        watch.elapsedMilliseconds(), 1000);
    SimSystem.report(Level.INFO, "WallClockTest: " + gaps.getGenerationCount()
        + " generations simulated.");
  }
View Full Code Here

    gaps.setNumIndividuals(NUM_OF_IND);
    ListOrAbort abortList = new ListOrAbort();
    abortList.addCriterion(new GenerationCountAbort(GEN_COUNT));
    abortList.addCriterion(new MaxFitnessAbort(MAXIMIZE_FITNESS));

    StopWatch watch = new StopWatch();
    watch.start();

    abortList.addCriterion(new WallClockTimeAbort(MILLISECONDS));
    gaps.setAbortCriterion(abortList);
    gaps.portfolio(problemDescription);
    watch.stop();

    assertTrue(
        "ListOrAbortTest: no abortCriteria fulfilled.",
        MILLISECONDS < watch.elapsedMilliseconds()
            || GEN_COUNT == gaps.getGenerationCount()
            || gaps.getBestFitness() >= MAXIMIZE_FITNESS);
    SimSystem.report(
        Level.INFO,
        "ListOrAbortTest: Fitness " + gaps.getBestFitness() + " reached in "
            + gaps.getGenerationCount() + " generations in "
            + watch.elapsedMilliseconds() + " milliseconds.");
  }
View Full Code Here

    // the counter used to find out how many loop passes had to be executed
    // before the minTime had been exceeded
    int c = 0;

    // stop watch used to find out the number of milliseconds elapsed
    StopWatch sw = new StopWatch();
    double e = 0.;
    do {
      c++;
      sw.start();
      for (int i = 0; i < OPS; i++) {
        // double e = 2.1 + 4.4;
        e /= 3d;
        e += 4.4e100d;
        e *= e;
        e -= 2d;
      }
      sw.stop();
      // System.out.println(sw.elapsedSeconds());
    } while (sw.elapsedMilliseconds() < MINTIME);

    // just here to make sure that not all computations on the local variables
    // are deleted by a compiler detecting that the result computed will not be
    // used later on
    fakeResult = e;

    return Double.valueOf(4d * c * OPSDONE / sw.elapsedSeconds() * 1.0e-6)
        .longValue();
  }
View Full Code Here

    // the counter used to find out how many loop passes had to be executed
    // before the minTime had been exceeded
    int c = 0;

    // stop watch used to find out the number of milliseconds elapsed
    StopWatch sw = new StopWatch();
    long l = 0;

    do {

      c++;
      sw.start();
      for (int i = 0; i < OPS; i++) {
        l /= 3l;
        l += 100987988798789l;
        l *= l;
        l -= 2l;
      }
      sw.stop();
    } while (sw.elapsedMilliseconds() < MINTIME);

    // just here to make sure that not all computations on the local variables
    // are deleted by a compiler detecting that the result computed will not be
    // used later on
    fakeResult = Double.valueOf(l);

    return Double.valueOf(4d * c * OPSDONE / sw.elapsedSeconds() * 1.0e-6)
        .longValue();

  }
View Full Code Here

    // the counter used to find out how many loop passes had to be executed
    // before the minTime had been exceeded
    int c = 0;

    // stop watch used to find out the number of milliseconds elapsed
    StopWatch sw = new StopWatch();

    int il = 0;

    do {
      c++;

      sw.start();
      for (int i = 0; i < OPS; i++) {
        il /= 3;
        il += 10098;
        il *= il;
        il -= 2;
      }
      sw.stop();
    } while (sw.elapsedMilliseconds() < MINTIME);

    // just here to make sure that not all computations on the local variables
    // are deleted by a compiler detecting that the result computed will not be
    // used later on
    fakeResult = Double.valueOf(il);

    return Double.valueOf(4d * c * OPSDONE / sw.elapsedSeconds() * 1.0e-6)
        .longValue();

  }
View Full Code Here

TOP

Related Classes of org.jamesii.core.util.StopWatch

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.