Examples of StopWatch


Examples of hivemall.utils.datetime.StopWatch

            logger.info("Forwarded the prediction model of " + numForwarded + " rows");
        }
    }

    protected void loadPredictionModel(Map<Object, PredictionModel> label2model, String filename, PrimitiveObjectInspector labelOI, PrimitiveObjectInspector featureOI) {
        final StopWatch elapsed = new StopWatch();
        final long lines;
        try {
            if(useCovariance()) {
                lines = loadPredictionModel(label2model, new File(filename), labelOI, featureOI, writableFloatObjectInspector, writableFloatObjectInspector);
            } else {
View Full Code Here

Examples of htsjdk.samtools.util.StopWatch

    }

    public void run() {
        final int ITERATIONS = 1000000;
        final String[] fields = new String[10000];
        final StopWatch watch = new StopWatch();

        watch.start();
        for (int i=0; i<ITERATIONS; ++i) {
            if (StringUtil.split(text, fields, '\t') > 100) {
                System.out.println("Mama Mia that's a lot of tokens!!");
            }
        }
        watch.stop();
        System.out.println("StringUtil.split() took " + watch.getElapsedTime());
        watch.reset();
       
        watch.start();
        for (int i=0; i<ITERATIONS; ++i) {
            if (split(text, fields, "\t") > 100) {
                System.out.println("Mama Mia that's a lot of tokens!!");
            }
        }
        watch.stop();
        System.out.println("StringTokenizer took " + watch.getElapsedTime());
    }
View Full Code Here

Examples of jersey.repackaged.com.google.common.base.Stopwatch

  @Nullable
  Map<K, V> loadAll(Set<? extends K> keys, CacheLoader<? super K, V> loader)
      throws ExecutionException {
    checkNotNull(loader);
    checkNotNull(keys);
    Stopwatch stopwatch = new Stopwatch().start();
    Map<K, V> result;
    boolean success = false;
    try {
      @SuppressWarnings("unchecked") // safe since all keys extend K
      Map<K, V> map = (Map<K, V>) loader.loadAll(keys);
      result = map;
      success = true;
    } catch (UnsupportedLoadingOperationException e) {
      success = true;
      throw e;
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new ExecutionException(e);
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Exception e) {
      throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } finally {
      if (!success) {
        globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      }
    }

    if (result == null) {
      globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      throw new InvalidCacheLoadException(loader + " returned null map from loadAll");
    }

    stopwatch.stop();
    // TODO(fry): batch by segment
    boolean nullsPresent = false;
    for (Map.Entry<K, V> entry : result.entrySet()) {
      K key = entry.getKey();
      V value = entry.getValue();
      if (key == null || value == null) {
        // delay failure until non-null entries are stored
        nullsPresent = true;
      } else {
        put(key, value);
      }
    }

    if (nullsPresent) {
      globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      throw new InvalidCacheLoadException(loader + " returned null keys or values from loadAll");
    }

    // TODO(fry): record count of loaded entries
    globalStatsCounter.recordLoadSuccess(stopwatch.elapsed(NANOSECONDS));
    return result;
  }
View Full Code Here

Examples of jp.vmi.selenium.selenese.utils.StopWatch

    @Test
    public void testJUnitResult() throws Exception {
        Calendar start = Calendar.getInstance();
        start.set(Calendar.MILLISECOND, 0);
        final ITestSuite testSuite = new ITestSuite() {
            private final StopWatch stopWatch = new StopWatch();

            @Override
            public String getBaseName() {
                return getName();
            }

            @Override
            public String getName() {
                return "test-suite";
            }

            @Override
            public boolean isError() {
                return false;
            }

            @Override
            public StopWatch getStopWatch() {
                return stopWatch;
            }
        };
        ITestCase[] testCases = new ITestCase[4];
        for (int i = 0; i < testCases.length; i++) {
            final int num = i;
            testCases[i] = new ITestCase() {
                private final StopWatch stopWatch = new StopWatch();
                private final LogRecorder logRecorder = new LogRecorder(System.out);

                @Override
                public String getBaseName() {
                    return getName();
                }

                @Override
                public String getName() {
                    return "test-case" + num;
                }

                @Override
                public boolean isError() {
                    return false;
                }

                @Override
                public StopWatch getStopWatch() {
                    return stopWatch;
                }

                @Override
                public void setLogRecorder(LogRecorder logRecorder) {
                    throw new UnsupportedOperationException();
                }

                @Override
                public LogRecorder getLogRecorder() {
                    return logRecorder;
                }
            };
        }
        jur.startTestSuite(testSuite);
        jur.addProperty(testSuite, "prop-name1", "prop-value1");
        jur.addProperty(testSuite, "prop-name2", "prop-value2");
        jur.addProperty(testSuite, "prop-name3", "prop-value3");
        ITestCase tc;
        StopWatch sw;
        LogRecorder clr;
        tc = testCases[0];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        testSuite.getStopWatch().start();
        sw.start();
        jur.setSuccess(tc);
        clr.info("systemOut00");
        clr.error("systemErr00");
        clr.info("systemOut01");
        clr.error("systemErr01");
        clr.info("systemOut02");
        clr.error("systemErr02");
        Thread.sleep(100);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[1];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        sw.start();
        jur.setError(tc, "detail1", "trace1");
        clr.info("systemOut1");
        clr.error("systemErr1");
        Thread.sleep(50);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[2];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        sw.start();
        jur.setFailure(tc, "detail2", "trace2");
        clr.info("systemOut2");
        clr.error("systemErr2");
        Thread.sleep(10);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[3];
        sw = tc.getStopWatch();
        jur.startTestCase(testSuite, tc);
        sw.start();
        sw.end();
        jur.endTestCase(tc);
        testSuite.getStopWatch().end();
        jur.endTestSuite(testSuite);
        jur.generateFailsafeSummary();
        dumpFiles();
View Full Code Here

Examples of jsprit.analysis.toolbox.StopWatch

     * Get schrimpf with threshold accepting
     * Note that Priority.LOW is a way to priorize AlgorithmListeners
     */
    VehicleRoutingAlgorithm vra_withThreshold = new SchrimpfFactory().createAlgorithm(vrp);
    vra_withThreshold.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/schrimpfThreshold_progress.png"), Priority.LOW);
    vra_withThreshold.getAlgorithmListeners().addListener(new StopWatch(), Priority.HIGH);
    /*
     * Get greedy schrimpf
     */
    VehicleRoutingAlgorithm vra_greedy = new GreedySchrimpfFactory().createAlgorithm(vrp);
    vra_greedy.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/schrimpfGreedy_progress.png"), Priority.LOW);
    vra_greedy.getAlgorithmListeners().addListener(new StopWatch(), Priority.HIGH);

    /*
     * run both
     */
    vra_withThreshold.searchSolutions();
 
View Full Code Here

Examples of jsprit.core.util.StopWatch

      calculateDistancesFromJob2Job();
    }
   
    private void calculateDistancesFromJob2Job() {
      logger.info("preprocess distances between locations ...");
      StopWatch stopWatch = new StopWatch();
      stopWatch.start();
      int nuOfDistancesStored = 0;
      for (Job i : vrp.getJobs().values()) {
        TreeSet<ReferencedJob> treeSet = new TreeSet<ReferencedJob>(
            new Comparator<ReferencedJob>() {
              @Override
              public int compare(ReferencedJob o1, ReferencedJob o2) {
                if (o1.getDistance() <= o2.getDistance()) {
                  return -1;
                } else {
                  return 1;
                }
              }
            });
        distanceNodeTree.put(i.getId(), treeSet);
        for (Job j : vrp.getJobs().values()) {
          if(i==j) continue;
          double distance = jobDistance.getDistance(i, j);
          ReferencedJob refNode = new ReferencedJob(j, distance);
          treeSet.add(refNode);
          nuOfDistancesStored++;
        }

      }
      stopWatch.stop();
      logger.info("preprocessing comp-time: " + stopWatch + "; nuOfDistances stored: " + nuOfDistancesStored + "; estimated memory: " +
          (distanceNodeTree.keySet().size()*64+nuOfDistancesStored*92) + " bytes");
    }
View Full Code Here

Examples of lejos.util.Stopwatch

   */
  static void showData(){
    LCD.clear();
    //int sentenceCount = 0;
   
    Stopwatch sw;
    sw = new Stopwatch();

    //boolean flag = true;
    int NSAT = 0;
    int GPSDataQuality = 0;
    int checkTime = 10000;
   
    //Circular System
    int GPSScreens = 8;
    int GPSCurrentScreen = 1;

    LCD.drawString(appName + " " + appVersion, 0,0);
   
    //FirstConnection
    boolean firstMomentFlag = false;

    while(!Button.ESCAPE.isPressed()){
      NSAT = gps.getSatellitesTracked();
      GPSDataQuality = Math.round((NSAT * 100)/4);
     
      LCD.drawString("        ", 9, 0);
      LCD.drawString(GPSDataQuality + "%", 9, 0);
      LCD.drawString("OK", 13, 0);
     
      if(sw.elapsed() >= checkTime){
        sw.reset();
        if(GPSDataQuality >=8){
          Sound.twoBeeps();
        }else if(GPSDataQuality >=4){
          Sound.beep();
        }else{
View Full Code Here

Examples of net.sf.rej.util.StopWatch

        // expand the root
        this.tree.expandPath(this.tree.getPathForRow(0));
       
        return; // early return
            }
            StopWatch watch = new StopWatch();
      SystemFacade.getInstance().setStatus("Preparing comparison.");           
           
            final ProgressMonitor pm = SystemFacade.getInstance().getProgressMonitor();

      // get a list of all the packages in the fileset
      final Set<String> pkgsAll = new TreeSet<String>();
      Set<String> pkgsA = new TreeSet<String>();
      for (String contentFile : this.listA) {
        int index = contentFile.lastIndexOf('/');
        if (index == -1) {
          pkgsAll.add("");
          pkgsA.add("");
        } else {
          String pkg = contentFile.substring(0, index);
          pkgsAll.add(pkg);
          pkgsA.add(pkg);
        }
       
      }
      Set<String> pkgsB = new TreeSet<String>();
      for (String contentFile : this.listB) {
        int index = contentFile.lastIndexOf('/');
        if (index == -1) {
          pkgsAll.add("");
          pkgsB.add("");
        } else {
          String pkg = contentFile.substring(0, index);
          pkgsAll.add(pkg);
          pkgsB.add(pkg);
        }
       
      }
     
      // associate each package name with a tree node
      Map<String, DefaultMutableTreeNode> map = new HashMap<String, DefaultMutableTreeNode>();
      for (String pkg : pkgsAll) {
        PackageItem pkgItem = new PackageItem(pkg);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(pkgItem);
        root.add(node);
        map.put(pkg, node);
       
        // style highlighting
        if (!pkgsA.contains(pkg)) {
          // only present in set B
          pkgItem.setStyle(Style.YELLOW);
        } else if (!pkgsB.contains(pkg)) {
          // only present in set A
          pkgItem.setStyle(Style.RED);
        } else {
          // present in both sets
          pkgItem.setStyle(Style.PLAIN);
        }
      }

      // sort
      Set<String> contentFileSet = new TreeSet<String>();
      contentFileSet.addAll(this.listA);
      contentFileSet.addAll(this.listB);
     
      // progress scope
     
      pm.setProgressScope(0, contentFileSet.size());
      int progress = 0;
      // add each file to the corresponding node
      for (String contentFile : contentFileSet) {
        SystemFacade.getInstance().setStatus("Comparing " + contentFile);           
        pm.setProgress(progress++);
        int index = contentFile.lastIndexOf('/');
        String pkg = "";
        if (index != -1) {
          pkg = contentFile.substring(0, index);
        }
        DefaultMutableTreeNode pkgNode = map.get(pkg);
        PackageItem pkgItem = (PackageItem) pkgNode.getUserObject();
        FileItem fileItem = null;
        if (index == -1) {
          fileItem = new FileItem(contentFile, contentFile);         
        } else {
          fileItem = new FileItem(contentFile.substring(pkg.length()+1), contentFile);
        }
        DefaultMutableTreeNode fileNode = new DefaultMutableTreeNode(fileItem);
        pkgNode.add(fileNode);
       
        // style highlighting
        if (!listA.contains(contentFile)) {
          // only in set B
          fileItem.setStyle(Style.YELLOW);
          if (pkgItem.getStyle() == Style.PLAIN) {
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        } else if (!listB.contains(contentFile)) {
          // only in set A
          fileItem.setStyle(Style.RED);
          if (pkgItem.getStyle() == Style.PLAIN) {
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        } else {
          // in both sets, compare (non-'java aware', simple binary compare)
          InputStream isA = this.filesetA.getInputStream(contentFile);
          InputStream isB = this.filesetB.getInputStream(contentFile);
          boolean eq = IOToolkit.areEqual(isA, isB);
          isA.close();
          isB.close();
          if (eq) {
            fileItem.setStyle(Style.PLAIN);
          } else {
            fileItem.setStyle(Style.RED_AND_YELLOW);
            pkgItem.setStyle(Style.RED_AND_YELLOW);
          }
        }
      }
      pm.setProgress(progress);

      // expand the root
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          tree.expandPath(tree.getPathForRow(0));       
          if (pkgsAll.size() == 1) {
            // only one package, expand it
            tree.expandPath(tree.getPathForRow(1));
          }
        }
      });
     
      SystemFacade.getInstance().setStatus("Compare done in " + watch.elapsedSeconds() + " seconds.");

        } catch (final Exception ee) {
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              SystemFacade.getInstance().handleException(ee)
View Full Code Here

Examples of net.sourceforge.processdash.util.Stopwatch

        this.defectFilename = defectFilename;
        this.defectPath = defectPath;
        defectLog = new DefectLog(defectFilename, defectPath.path(),
                                  dash.getData());
        date = new Date();
        stopwatch = new Stopwatch(false);
        stopwatch.setMultiplier(Settings.getVal("timer.multiplier"));
        stopwatchSynchronizer = new StopwatchSynchronizer(dash
                .getTimeLoggingModel());

        JPanel panel = new JPanel();
View Full Code Here

Examples of org.apache.camel.util.StopWatch

    @Override
    protected void doSuspend() throws Exception {
        EventHelper.notifyCamelContextSuspending(this);

        log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is suspending");
        StopWatch watch = new StopWatch();

        // update list of started routes to be suspended
        // because we only want to suspend started routes
        // (so when we resume we only resume the routes which actually was suspended)
        for (Map.Entry<String, RouteService> entry : getRouteServices().entrySet()) {
            if (entry.getValue().getStatus().isStarted()) {
                suspendedRouteServices.put(entry.getKey(), entry.getValue());
            }
        }

        // assemble list of startup ordering so routes can be shutdown accordingly
        List<RouteStartupOrder> orders = new ArrayList<RouteStartupOrder>();
        for (Map.Entry<String, RouteService> entry : suspendedRouteServices.entrySet()) {
            Route route = entry.getValue().getRoutes().iterator().next();
            Integer order = entry.getValue().getRouteDefinition().getStartupOrder();
            if (order == null) {
                order = defaultRouteStartupOrder++;
            }
            orders.add(new DefaultRouteStartupOrder(order, route, entry.getValue()));
        }

        // suspend routes using the shutdown strategy so it can shutdown in correct order
        // routes which doesn't support suspension will be stopped instead
        getShutdownStrategy().suspend(this, orders);

        // mark the route services as suspended or stopped
        for (RouteService service : suspendedRouteServices.values()) {
            if (routeSupportsSuspension(service.getId())) {
                service.suspend();
            } else {
                service.stop();
            }
        }

        watch.stop();
        if (log.isInfoEnabled()) {
            log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is suspended in " + TimeUtils.printDuration(watch.taken()));
        }

        EventHelper.notifyCamelContextSuspended(this);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.