protected long measure(String prefix, int numIterations, Runnable r) {
    final int logInterval = 5 * 1000;
    long nextLogTime = logInterval;

    // Give it some warm-up cycles
    Stopwatch warmupWatch = Stopwatch.createStarted();
    for (int i = 0; i < (numIterations / 10); i++) {
      if (warmupWatch.elapsed(TimeUnit.MILLISECONDS) >= nextLogTime) {
        LOG.info(
            "Warm-up "
                + prefix
                + " iteration="
                + i
                + " at "
                + warmupWatch.elapsed(TimeUnit.MILLISECONDS)
                + "ms");
        nextLogTime += logInterval;
      }
      r.run();
    }

    Stopwatch stopwatch = Stopwatch.createStarted();
    nextLogTime = 0;
    for (int i = 0; i < numIterations; i++) {
      if (stopwatch.elapsed(TimeUnit.MILLISECONDS) >= nextLogTime) {
        LOG.info(
            prefix + " iteration=" + i + " at " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
        nextLogTime += logInterval;
      }
      r.run();
    }
    return stopwatch.elapsed(TimeUnit.MILLISECONDS);
  }
Ejemplo n.º 2
0
  protected void createAndRunAServiceInGroup(String group) throws RunNodesException {
    // note that some cloud providers do not support mixed case tag names
    ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String>of("test", group);

    ImmutableSet<String> tags = ImmutableSet.of(group);
    Stopwatch watch = Stopwatch.createStarted();

    template = buildTemplate(client.templateBuilder());
    template
        .getOptions()
        .inboundPorts(22, 8080)
        .blockOnPort(22, 300)
        .userMetadata(userMetadata)
        .tags(tags);

    NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template));
    long createSeconds = watch.elapsed(TimeUnit.SECONDS);

    final String nodeId = node.getId();

    checkUserMetadataContains(node, userMetadata);
    checkTagsInNodeEquals(node, tags);

    getAnonymousLogger()
        .info(
            format(
                "<< available node(%s) os(%s) in %ss",
                node.getId(), node.getOperatingSystem(), createSeconds));

    watch.reset().start();

    client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty"));

    long configureSeconds = watch.elapsed(TimeUnit.SECONDS);

    getAnonymousLogger()
        .info(
            format(
                "<< configured node(%s) with %s and jetty %s in %ss",
                nodeId,
                exec(nodeId, "java -fullversion"),
                exec(nodeId, JettyStatements.version()),
                configureSeconds));

    trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node);

    client.runScriptOnNode(
        nodeId, JettyStatements.stop(), runAsRoot(false).wrapInInitScript(false));

    trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node);
  }
Ejemplo n.º 3
0
 @Override
 public void methodFinished() {
   // TODO(beder): Is a system ticker the appropriate way to track CPU time? Should we use
   // ThreadCpuTicker instead?
   long durationNanos = stopwatch.elapsed(NANOSECONDS);
   recorder.recordMethod(startNanos, durationNanos);
 }
Ejemplo n.º 4
0
  public Iterable<MeasurementDataNumericHighLowComposite> findDataForResource(
      int scheduleId, long beginTime, long endTime, int numberOfBuckets) {
    Stopwatch stopwatch = new Stopwatch().start();
    try {
      DateTime begin = new DateTime(beginTime);

      if (dateTimeService.isInRawDataRange(begin)) {
        Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleId, beginTime, endTime);
        return createRawComposites(metrics, beginTime, endTime, numberOfBuckets);
      }

      List<AggregateNumericMetric> metrics = null;
      if (dateTimeService.isIn1HourDataRange(begin)) {
        metrics = dao.findAggregateMetrics(scheduleId, Bucket.ONE_HOUR, beginTime, endTime);
        return createComposites(metrics, beginTime, endTime, numberOfBuckets);
      } else if (dateTimeService.isIn6HourDataRange(begin)) {
        metrics = dao.findAggregateMetrics(scheduleId, Bucket.SIX_HOUR, beginTime, endTime);
        return createComposites(metrics, beginTime, endTime, numberOfBuckets);
      } else if (dateTimeService.isIn24HourDataRange(begin)) {
        metrics = dao.findAggregateMetrics(scheduleId, Bucket.TWENTY_FOUR_HOUR, beginTime, endTime);
        return createComposites(metrics, beginTime, endTime, numberOfBuckets);
      } else {
        throw new IllegalArgumentException(
            "beginTime[" + beginTime + "] is outside the accepted range.");
      }
    } finally {
      stopwatch.stop();
      if (log.isDebugEnabled()) {
        log.debug(
            "Finished calculating resource summary aggregate in "
                + stopwatch.elapsed(TimeUnit.MILLISECONDS)
                + " ms");
      }
    }
  }
  private void testFull(
      QueryType type,
      String planText,
      String filename,
      int numberOfTimesRead /* specified in json plan */,
      int numberOfRowGroups,
      int recordsPerRowGroup,
      boolean testValues)
      throws Exception {

    //    RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator());
    HashMap<String, FieldInfo> fields = new HashMap<>();
    ParquetTestProperties props =
        new ParquetTestProperties(
            numberRowGroups, recordsPerRowGroup, DEFAULT_BYTES_PER_PAGE, fields);
    TestFileGenerator.populateFieldInfoMap(props);
    ParquetResultListener resultListener =
        new ParquetResultListener(getAllocator(), props, numberOfTimesRead, testValues);
    Stopwatch watch = new Stopwatch().start();
    testWithListener(type, planText, resultListener);
    resultListener.getResults();
    //    batchLoader.clear();
    System.out.println(
        String.format("Took %d ms to run query", watch.elapsed(TimeUnit.MILLISECONDS)));
  }
  public HashMap<String, byte[]> digestDependencies(List<File> dependencies) throws IOException {
    Stopwatch stopwatch = Stopwatch.createStarted();

    HashMap<String, byte[]> digest = new HashMap<String, byte[]>();

    // scan dependencies backwards to properly deal with duplicate type definitions
    for (int i = dependencies.size() - 1; i >= 0; i--) {
      File file = dependencies.get(i);
      if (file.isFile()) {
        digest.putAll(digestJar(file));
      } else if (file.isDirectory()) {
        digest.putAll(digestDirectory(file));
      } else {
        // happens with reactor dependencies with empty source folders
        continue;
      }
    }

    log.debug(
        "Analyzed {} classpath dependencies ({} ms)",
        dependencies.size(),
        stopwatch.elapsed(TimeUnit.MILLISECONDS));

    return digest;
  }
Ejemplo n.º 7
0
  protected void testAction(JdbcAction action, long rowcount) throws Exception {
    int rows = 0;
    Stopwatch watch = Stopwatch.createStarted();
    ResultSet r = action.getResult(connection);
    boolean first = true;
    while (r.next()) {
      rows++;
      ResultSetMetaData md = r.getMetaData();
      if (first == true) {
        for (int i = 1; i <= md.getColumnCount(); i++) {
          System.out.print(md.getColumnName(i));
          System.out.print('\t');
        }
        System.out.println();
        first = false;
      }

      for (int i = 1; i <= md.getColumnCount(); i++) {
        System.out.print(r.getObject(i));
        System.out.print('\t');
      }
      System.out.println();
    }

    System.out.println(
        String.format("Query completed in %d millis.", watch.elapsed(TimeUnit.MILLISECONDS)));

    if (rowcount != -1) {
      Assert.assertEquals((long) rowcount, (long) rows);
    }

    System.out.println("\n\n\n");
  }
  @Override
  public SOid fromString(final String from) throws Exception {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(String.format("fromString(from=%s)", from));
    }
    final SOid oid;
    final Stopwatch stopwatch = Stopwatch.createStarted();
    try {
      final String split[] = from.split(":");
      Assert.isTrue(
          split.length == 3,
          String.format("OID[%s] is invalid, it should be in format A:B:C", from));

      final String oidPrefix = split[TYPE_PREFIX_INDEX];
      final Class<?> oidClass = Class.forName(split[CLASS_NAME_INDEX]);
      final String oidId = split[ID_INDEX];

      oid = this.getOidObject(oidPrefix, oidClass, oidId);
    } catch (Exception exp) {
      LOGGER.error(
          String.format("fromString(from=%s) failed...", from), Throwables.getRootCause(exp));
      throw exp;
    }

    stopwatch.stop();

    if (LOGGER.isTraceEnabled()) {
      final long elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
      LOGGER.trace(
          String.format("fromString(from=%s) to SOid(oid=%s) took %d ms", from, oid, elapsed));
    }

    return oid;
  }
 private void doParseSentencesInCorpus(File ntvmsnbcCorpus) throws IOException {
   /* SentenceMorphParse parse = parser.parse("Turgut Özal'ın ölüm raporu ile ilgili flaş bir gelişme.");
   parse.dump();
   System.out.println("After disambiguation:");
   parser.disambiguate(parse);
   parse.dump();
   for (SentenceMorphParse.Entry entry : parse) {
       System.out.println(entry.input + "=" + entry.parses.get(0));
   }
   for (SentenceMorphParse.Entry entry : parse) {
       System.out.println(entry.input + " kök=" + entry.parses.get(0).stem);
   }*/
   List<String> sentences = SimpleTextReader.trimmingUTF8Reader(ntvmsnbcCorpus).asStringList();
   Stopwatch sw = new Stopwatch().start();
   int wc = 0;
   for (String sentence : sentences) {
     SentenceMorphParse parse = parser.parse(sentence);
     wc += parse.size();
     parser.disambiguate(parse);
     // System.out.println(sentence);
     // parse.dump();
   }
   System.out.println(wc);
   System.out.println(sw.elapsed(TimeUnit.MILLISECONDS));
 }
Ejemplo n.º 10
0
  public AggregateNumericMetric getSummaryAggregate(
      List<Integer> scheduleIds, long beginTime, long endTime) {
    Stopwatch stopwatch = new Stopwatch().start();
    try {
      DateTime begin = new DateTime(beginTime);

      if (dateTimeService.isInRawDataRange(new DateTime(beginTime))) {
        Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleIds, beginTime, endTime);
        return calculateAggregatedRaw(metrics, beginTime);
      }
      Bucket bucket = getBucket(begin);
      List<AggregateNumericMetric> metrics = loadMetrics(scheduleIds, beginTime, endTime, bucket);

      return calculateAggregate(metrics, beginTime, bucket);
    } finally {
      stopwatch.stop();
      if (log.isDebugEnabled()) {
        log.debug(
            "Finished calculating group summary aggregate for [scheduleIds: "
                + scheduleIds
                + ", beginTime: "
                + beginTime
                + ", endTime: "
                + endTime
                + "] in "
                + stopwatch.elapsed(TimeUnit.MILLISECONDS)
                + " ms");
      }
    }
  }
  @Override
  public void write(OntologyVersion o, Collection<Statement> statements)
      throws IOException, ParseException {
    LOG.debug(
        "Exporting to Meta Snomed Model in TriG format. \nGraph name is <" + GRAPH_NAME + ">");
    Stopwatch stopwatch = new Stopwatch().start();

    int counter = 1;
    for (Concept c : o.getConcepts()) {
      parse(c);
      counter++;
      if (counter % 10000 == 0) {
        LOG.info("Processed {} concepts", counter);
      }
    }

    counter = 1;
    for (Statement s : statements) {
      write(s);
      counter++;
      if (counter % 10000 == 0) {
        LOG.info("Processed {} statements", counter);
      }
    }
    footer();

    stopwatch.stop();
    LOG.info("Completed Meta Snomed export in " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");
  }
Ejemplo n.º 12
0
 /**
  * DO NOT RUN!!!!
  *
  * @author Joshua Barlin (propoke24)
  * @version 1
  * @return Time between execution and interruption
  * @deprecated Test Code
  */
 @Deprecated
 public static long timer() {
   final Stopwatch stopwatch = Stopwatch.createUnstarted();
   stopwatch.start();
   stopwatch.stop();
   return stopwatch.elapsed(TimeUnit.SECONDS);
 }
 @Test
 public void testInessentialChildrenFailureDoesNotAbortSecondaryOrFailPrimary() {
   Task<String> t1 = monitorableTask(null, "1", new FailCallable());
   TaskTags.markInessential(t1);
   Task<String> t =
       Tasks.<String>builder()
           .dynamic(true)
           .body(monitorableJob("main"))
           .add(t1)
           .add(monitorableTask("2"))
           .build();
   ec.submit(t);
   releaseAndWaitForMonitorableJob("1");
   Assert.assertFalse(t.blockUntilEnded(TINY_TIME));
   releaseAndWaitForMonitorableJob("2");
   Assert.assertFalse(t.blockUntilEnded(TINY_TIME));
   releaseMonitorableJob("main");
   Assert.assertTrue(t.blockUntilEnded(TIMEOUT));
   Assert.assertEquals(messages, MutableList.of("1", "2", "main"));
   Assert.assertTrue(
       stopwatch.elapsed(TimeUnit.MILLISECONDS) < TIMEOUT.toMilliseconds(),
       "took too long: " + stopwatch);
   Assert.assertFalse(t.isError());
   Assert.assertTrue(t1.isError());
 }
Ejemplo n.º 14
0
  public static <T extends CompleteWork> List<EndpointAffinity> getAffinityMap(List<T> work) {
    Stopwatch watch = new Stopwatch();

    long totalBytes = 0;
    for (CompleteWork entry : work) {
      totalBytes += entry.getTotalBytes();
    }

    ObjectFloatOpenHashMap<DrillbitEndpoint> affinities =
        new ObjectFloatOpenHashMap<DrillbitEndpoint>();
    for (CompleteWork entry : work) {
      for (ObjectLongCursor<DrillbitEndpoint> cursor : entry.getByteMap()) {
        long bytes = cursor.value;
        float affinity = (float) bytes / (float) totalBytes;
        logger.debug("Work: {} Endpoint: {} Bytes: {}", work, cursor.key.getAddress(), bytes);
        affinities.putOrAdd(cursor.key, affinity, affinity);
      }
    }

    List<EndpointAffinity> affinityList = Lists.newLinkedList();
    for (ObjectFloatCursor<DrillbitEndpoint> d : affinities) {
      logger.debug("Endpoint {} has affinity {}", d.key.getAddress(), d.value);
      affinityList.add(new EndpointAffinity(d.key, d.value));
    }

    logger.debug("Took {} ms to get operator affinity", watch.elapsed(TimeUnit.MILLISECONDS));
    return affinityList;
  }
  @Override
  protected void shutDown() throws Exception {
    LOG.debug("Stopping InputSetupService");
    eventBus.unregister(this);

    for (InputState state : inputRegistry.getRunningInputs()) {
      MessageInput input = state.getMessageInput();

      LOG.info(
          "Attempting to close input <{}> [{}].", input.getUniqueReadableId(), input.getName());

      Stopwatch s = Stopwatch.createStarted();
      try {
        input.stop();

        LOG.info(
            "Input <{}> closed. Took [{}ms]",
            input.getUniqueReadableId(),
            s.elapsed(TimeUnit.MILLISECONDS));
      } catch (Exception e) {
        LOG.error(
            "Unable to stop input <{}> [{}]: " + e.getMessage(),
            input.getUniqueReadableId(),
            input.getName());
      } finally {
        s.stop();
      }
    }
    LOG.debug("Stopped InputSetupService");
  }
Ejemplo n.º 16
0
 private synchronized Duration elapsedErrorDuration() {
   if (errorStopwatch.isRunning()) {
     errorStopwatch.stop();
   }
   long nanos = errorStopwatch.elapsed(TimeUnit.NANOSECONDS);
   return new Duration(nanos, TimeUnit.NANOSECONDS).convertTo(TimeUnit.SECONDS);
 }
 @Override
 public final D scan(I container, String path, Scope scope, Scanner scanner) throws IOException {
   ScannerContext context = scanner.getContext();
   D containerDescriptor = getContainerDescriptor(container, context);
   String containerPath = getContainerPath(container, path);
   containerDescriptor.setFileName(containerPath);
   LOGGER.info("Entering {}", containerPath);
   ContainerFileResolver fileResolverStrategy = new ContainerFileResolver(containerDescriptor);
   context.push(FileResolver.class, fileResolverStrategy);
   enterContainer(container, containerDescriptor, scanner.getContext());
   Stopwatch stopwatch = Stopwatch.createStarted();
   try {
     Iterable<? extends E> entries = getEntries(container);
     for (E entry : entries) {
       String relativePath = getRelativePath(container, entry);
       try (Resource resource = getEntry(container, entry)) {
         LOGGER.debug("Scanning {}", relativePath);
         FileDescriptor descriptor = scanner.scan(resource, relativePath, scope);
         fileResolverStrategy.put(relativePath, descriptor);
       }
     }
   } finally {
     leaveContainer(container, containerDescriptor, scanner.getContext());
     context.pop(FileResolver.class);
   }
   fileResolverStrategy.flush();
   LOGGER.info(
       "Leaving {} ({} entries, {} ms)",
       containerPath,
       fileResolverStrategy.size(),
       stopwatch.elapsed(MILLISECONDS));
   return containerDescriptor;
 }
Ejemplo n.º 18
0
  @Override
  public List<EndpointAffinity> getOperatorAffinity() {
    watch.reset();
    watch.start();
    Map<String, DrillbitEndpoint> endpointMap = new HashMap<String, DrillbitEndpoint>();
    for (DrillbitEndpoint ep : storagePlugin.getContext().getBits()) {
      endpointMap.put(ep.getAddress(), ep);
    }

    Map<DrillbitEndpoint, EndpointAffinity> affinityMap =
        new HashMap<DrillbitEndpoint, EndpointAffinity>();
    for (ServerName sn : regionsToScan.values()) {
      DrillbitEndpoint ep = endpointMap.get(sn.getHostname());
      if (ep != null) {
        EndpointAffinity affinity = affinityMap.get(ep);
        if (affinity == null) {
          affinityMap.put(ep, new EndpointAffinity(ep, 1));
        } else {
          affinity.addAffinity(1);
        }
      }
    }
    logger.debug("Took {} µs to get operator affinity", watch.elapsed(TimeUnit.NANOSECONDS) / 1000);
    return Lists.newArrayList(affinityMap.values());
  }
Ejemplo n.º 19
0
  public static void main(String[] args) {
    Stopwatch timer = Stopwatch.createStarted();
    OptionsParser optionsParser = OptionsParser.newOptionsParser(Options.class);
    optionsParser.parseAndExitUponError(args);
    Options options = optionsParser.getOptions(Options.class);

    checkFlags(options);

    FileSystem fileSystem = FileSystems.getDefault();
    Path working = fileSystem.getPath("").toAbsolutePath();

    AndroidResourceProcessor resourceProcessor =
        new AndroidResourceProcessor(new StdLogger(com.android.utils.StdLogger.Level.VERBOSE));

    try {
      Path resourcesOut = Files.createTempDirectory("tmp-resources");
      resourcesOut.toFile().deleteOnExit();
      Path assetsOut = Files.createTempDirectory("tmp-assets");
      assetsOut.toFile().deleteOnExit();
      logger.fine(String.format("Setup finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));

      ImmutableList<DirectoryModifier> modifiers =
          ImmutableList.of(
              new PackedResourceTarExpander(working.resolve("expanded"), working),
              new FileDeDuplicator(
                  Hashing.murmur3_128(), working.resolve("deduplicated"), working));
      MergedAndroidData mergedData =
          resourceProcessor.mergeData(
              options.mainData,
              options.dependencyData,
              resourcesOut,
              assetsOut,
              modifiers,
              null,
              options.strictMerge);
      logger.info(String.format("Merging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));

      writeAar(options.aarOutput, mergedData, options.manifest, options.rtxt, options.classes);
      logger.info(
          String.format("Packaging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));

    } catch (IOException | MergingException e) {
      logger.log(Level.SEVERE, "Error during merging resources", e);
      System.exit(1);
    }
    System.exit(0);
  }
Ejemplo n.º 20
0
 @Override
 public void failed(Throwable t) {
   if (stopwatch.isRunning()) {
     long latencyNanos = stopwatch.elapsed(NANOSECONDS);
     recorder.recordFailure(t, latencyNanos);
   } else {
     recorder.recordSkip(t);
   }
 }
Ejemplo n.º 21
0
  public static void main(String[] args) {
    Stopwatch sw = Stopwatch.createStarted();
    for (int y = 0; y < 10; ++y) {
      new CartesianIteratorTest().testCartesianProduct();

      // System.out.println("done[" + y + "]: " + i);
    }
    System.out.println(sw.elapsed(TimeUnit.MILLISECONDS));
  }
Ejemplo n.º 22
0
 @Test
 public void testMillionsExeWithAnnotation() {
   Stopwatch stopwatch = Stopwatch.createStarted();
   int size = 1000 * 1000;
   for (int i = 0; i < size; i++) {
     cacheDemo.getUserMock(i);
   }
   stopwatch.stop();
   System.out.println(stopwatch.elapsed(TimeUnit.MILLISECONDS));
 }
Ejemplo n.º 23
0
  @Mod.EventHandler
  public void postInit(FMLPostInitializationEvent event) {
    final Stopwatch stopwatch = Stopwatch.createStarted();
    logHelper.info("Post Initialization (Started)");

    IntegrationsManager.instance().postInit();

    logHelper.info(
        "Post Initialization (Ended after " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms)");
  }
Ejemplo n.º 24
0
 @Override
 public void submissionFailed(UserException ex) {
   exception = ex;
   System.out.println(
       "Exception (no rows returned): "
           + ex
           + ".  Returned in "
           + w.elapsed(TimeUnit.MILLISECONDS)
           + "ms.");
   latch.countDown();
 }
Ejemplo n.º 25
0
 @Override
 public void queryCompleted(QueryState state) {
   DrillAutoCloseables.closeNoChecked(allocator);
   latch.countDown();
   System.out.println(
       "Total rows returned : "
           + count.get()
           + ".  Returned in "
           + w.elapsed(TimeUnit.MILLISECONDS)
           + "ms.");
 }
  @Before
  public void beforeTestIsRunning() {
    final Stopwatch stopwatch = startJetty(jetty());
    testIndex()
        .recordInfo(
            "startup time",
            stopwatch.elapsed(TimeUnit.MILLISECONDS) == 0
                ? "already running"
                : stopwatch.toString());

    assertThat("Jetty is running before test starts", jetty().isRunning(), is(true));
  }
Ejemplo n.º 27
0
 @Test
 public void stringKeys() throws IOException {
   int[] limits = {1, 2, 10, 100, 1000, 50000, 100000};
   int strSize = 5;
   for (int limit : limits) {
     System.out.println("Key amount: " + limit);
     Stopwatch sw = new Stopwatch().start();
     StringHashKeyProvider provider = new StringHashKeyProvider(uniqueStrings(limit, strSize));
     System.out.println("Generation:" + sw.elapsed(TimeUnit.MILLISECONDS));
     generateAndTest(provider);
   }
 }
Ejemplo n.º 28
0
  /**
   * This constructor initializes the engine by initializing its systems, subsystems and managers.
   * It also verifies that some required systems are up and running after they have been
   * initialized.
   *
   * @param subsystems Typical subsystems lists contain graphics, timer, audio and input subsystems.
   */
  public TerasologyEngine(Collection<EngineSubsystem> subsystems) {

    Stopwatch totalInitTime = Stopwatch.createStarted();

    this.subsystems = Queues.newArrayDeque(subsystems);

    try {
      logger.info("Initializing Terasology...");
      logEnvironmentInfo();

      SplashScreen.getInstance().post("Loading config file ...");

      initConfig();

      SplashScreen.getInstance().post("Pre-initialize subsystems ...");

      preInitSubsystems();

      // time must be set here as it is required by some of the managers.
      verifyRequiredSystemIsRegistered(Time.class);
      time = (EngineTime) CoreRegistry.get(Time.class);

      GameThread.setToCurrentThread();

      initManagers();

      SplashScreen.getInstance().post("Post-initialize subsystems ...");

      postInitSubsystems();

      verifyRequiredSystemIsRegistered(DisplayDevice.class);
      verifyRequiredSystemIsRegistered(RenderingSubsystemFactory.class);
      verifyRequiredSystemIsRegistered(InputSystem.class);

      SplashScreen.getInstance().post("Initialize assets ...");

      initAssets();

      // TODO: Review - The advanced monitor shouldn't be hooked-in this way (see issue #692)
      initAdvancedMonitor();

      engineState = EngineState.INITIALIZED;

    } catch (RuntimeException e) {
      logger.error("Failed to initialise Terasology", e);
      cleanup();
      throw e;
    }

    double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS);
    logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds));
  }
Ejemplo n.º 29
0
 public static FileSelection create(
     final DrillFileSystem fs, final String parent, final String path) throws IOException {
   Stopwatch timer = Stopwatch.createStarted();
   final Path combined = new Path(parent, removeLeadingSlash(path));
   final FileStatus[] statuses = fs.globStatus(combined);
   if (statuses == null) {
     return null;
   }
   final FileSelection fileSel =
       create(Lists.newArrayList(statuses), null, combined.toUri().toString());
   logger.debug("FileSelection.create() took {} ms ", timer.elapsed(TimeUnit.MILLISECONDS));
   return fileSel;
 }
Ejemplo n.º 30
0
 public void test(File testFile) throws IOException {
   DataSet testSet = Files.readLines(testFile, Charsets.UTF_8, new DataSetLoader());
   int hit = 0, total = 0;
   Stopwatch sw = Stopwatch.createStarted();
   Random r = new Random(5);
   for (SentenceData sentence : testSet.sentences) {
     for (Z3WordData word : sentence.words) {
       Collections.shuffle(word.allParses, r);
     }
     Ambiguous[] seq = getAmbiguousSequence(sentence);
     int[] bestSeq = bestSequence(seq);
     int j = 0;
     for (int parseIndex : bestSeq) {
       Z3WordData wordData = sentence.words.get(j);
       if (wordData.allParses.get(parseIndex).equals(wordData.correctParse)) {
         hit++;
       } else {
         System.out.println(
             "miss:"
                 + wordData.word
                 + " Correct:"
                 + wordData.correctParse
                 + " : "
                 + wordData.allParses.get(parseIndex));
       }
       total++;
       j++;
     }
   }
   System.out.println("Elapsed: " + sw.elapsed(TimeUnit.MILLISECONDS) + "ms.");
   System.out.println("Total: " + total + " hit: " + hit);
   System.out.println(String.format("Accuracy:%.3f%%", (double) hit / total * 100));
   if (sw.elapsed(TimeUnit.MILLISECONDS) > 0) {
     System.out.println(
         "Approximate performance: "
             + (1000L * total / sw.elapsed(TimeUnit.MILLISECONDS))
             + " per second.");
   }
 }