Examples of StopWatch


Examples of org.apache.commons.lang.time.StopWatch

    // warm up the mapper
    mapper.map(src, destClass);

    // perform x number of additional mappings
    log.info("Begin timings for " + testName);
    StopWatch timer = new StopWatch();
    timer.start();
    for (int i = 0; i < numIters; i++) {
      mapper.map(src, destClass);
    }
    timer.stop();
    log.info("Total time for additional " + numIters + " mappings: " + timer.getTime() + " milliseconds");
    log.info("avg time for " + numIters + " mappings: " + (timer.getTime() / numIters) + " milliseconds");
  }
View Full Code Here

Examples of org.apache.commons.lang3.time.StopWatch

     * Renumber rn = RenumberUtils.getSiblingRenumber("", 1);
     *
     * System.out.println(rn.renumber()); System.out.println(rn.renumber()); System.out.println(rn.renumber()); System.out.println(rn.renumber()); System.out.println(rn.renumber()); System.out.println(rn.renumber());
     */

    StopWatch sw = new StopWatch();
    RenumberUtils.Renumber hierRenumber = RenumberUtils.getHierRenumber("001.001", 1);
    sw.start();
    // System.out.println("4: " + hierRenumber.renumber(4));
    // System.out.println("\t5: " + hierRenumber.renumber(5));
    // System.out.println("\t5: " + hierRenumber.renumber(5));
    // System.out.println("\t\t6: " + hierRenumber.renumber(6));
    // System.out.println("\t5: " + hierRenumber.renumber(5));
    // System.out.println("\t\t6: " + hierRenumber.renumber(6));
    // System.out.println("\t\t\t7: " + hierRenumber.renumber(7));
    // System.out.println("\t\t\t\t8: " + hierRenumber.renumber(8));
    // System.out.println("\t\t\t7: " + hierRenumber.renumber(7));
    // System.out.println("\t\t\t7: " + hierRenumber.renumber(7));
    // System.out.println("\t5: " + hierRenumber.renumber(5));
    // System.out.println("\t5: " + hierRenumber.renumber(5));
    // System.out.println("\t\t6: " + hierRenumber.renumber(6));
    // System.out.println("\t\t6: " + hierRenumber.renumber(6));
    // System.out.println("\t\t6: " + hierRenumber.renumber(6));
    // System.out.println("\t\t\t7: " + hierRenumber.renumber(7));
    // System.out.println("\t\t\t7: " + hierRenumber.renumber(7));
    sw.stop();
    System.out.println(sw.toString());
    sw.reset();
    hierRenumber = RenumberUtils.getIncrementRenumber("[###]", 0);
    System.out.println("\t\t\t7: " + hierRenumber.renumber());
    System.out.println("\t\t\t7: " + hierRenumber.renumber());
    System.out.println("\t\t\t7: " + hierRenumber.renumber());
    System.out.println("\t\t\t7: " + hierRenumber.renumber());
View Full Code Here

Examples of org.apache.fulcrum.yaafi.interceptor.util.StopWatch

    {
        if( this.getLogger().isErrorEnabled() )
        {
          if( this.isMonitorAllExceptions() || this.isServiceMonitored(interceptorContext) )
          {
              StopWatch stopWatch = this.getStopWatch(interceptorContext);
              stopWatch.stop();
              String msg = this.toString(interceptorContext, stopWatch, t);
              this.getLogger().error(msg);
          }
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.util.StopWatch

    // run the micro-benchmark
    public static void main(String... args) {
        for (int k = 0; k < 5; k++) {
            // String s = "Hello World Hello World Hello World Hello World Hello World Hello World ";
            String s = "Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" ";
            StopWatch timer = new StopWatch();
            int t2 = 0;
            for (int i = 0; i < 1000000; i++) {
                t2 += JsopBuilder.encode(s).length();
            }
            System.out.println(timer.seconds() + " dummy: " + t2);
        }
        // old: not escaped: 5691 ms; escaped: 10609 ms
        // new: not escaped: 3931 ms; escaped: 11001 ms
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.commons.StopWatch

    // run the micro-benchmark
    public static void main(String... args) {
        for (int k = 0; k < 5; k++) {
            String s = "Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" Hello \"World\" ";
            StopWatch timer = new StopWatch();
            JsopWriter w = k % 2 == 1 ? new JsopBuilder() : new JsopStream();
            for (int i = 0; i < 1000000; i++) {
                w.value(s);
                if (i % 100 == 0) {
                    w.resetWriter();
                }
            }
            System.out.println(w.getClass() + ": " + timer.seconds());
        }
        // JsopStream: 20
        // JsopBuilder: 1150
    }
View Full Code Here

Examples of org.apache.niolex.commons.test.StopWatch

  /**
   * @param args
   */
  public static void main(String[] args) {
    StopWatch w = new StopWatch(1);
    w.begin(true);
    // This is slower!
    for (int i = 0; i < 1000; ++i) {
        IntList inList = new ArrayIntList(10000);
      Stop s = w.start();
      for (int j = 0; j < 10000; ++j) {
        inList.add(j);
      }
      s.stop();
    }
    w.done();
    w.print();
    // ------------
    w = new StopWatch(1);
    w.begin(true);
    for (int i = 0; i < 1000; ++i) {
        ArrayList<Integer> oList = new ArrayList<Integer>(10000);
      Stop s = w.start();
      for (int j = 0; j < 10000; ++j) {
        oList.add(j);
      }
      s.stop();
    }
    w.done();
    w.print();
  }
View Full Code Here

Examples of org.apache.sirona.stopwatches.StopWatch

    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        final String name = method.getName();
        if (name.startsWith("execute")) {
            final StopWatch stopWatch;
            if (name.endsWith("Batch") && (args == null || args.length == 0)) {
                stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, "batch")));
            } else {
                stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, (String) args[0])));
            }

            try {
                return doInvoke(method, args);
            } catch (final InvocationTargetException e) {
                throw extractSQLException(e);
            } finally {
                stopWatch.stop();
            }
        }
        return doInvoke(method, args);
    }
View Full Code Here

Examples of org.apache.xindice.Stopwatch

                for (int i = 0; i < list.length; i++) {
                    log.trace("Index Creation: " + list[i].indexer.getName());
                }
            }

            Stopwatch sw = new Stopwatch("Populated Indexes", true);
            RecordSet rs = collection.getFiler().getRecordSet();
            while (rs.hasMoreRecords()) {
                // Read only key, we don't need filer-level value
                Key key = rs.getNextKey();
                Object value = collection.getEntry(key);
                if (value instanceof Document) {
                    try {
                        new SAXHandler(key, (Document)value, ACTION_CREATE, list);
                    } catch (Exception e) {
                        if (log.isWarnEnabled()) {
                            log.warn("Failed to index document " + key, e);
                        }
                    }
                }
            }

            for (int i = 0; i < list.length; i++) {
                try {
                    list[i].indexer.flush();
                } catch (Exception e) {
                    if (log.isWarnEnabled()) {
                        log.warn("ignored exception", e);
                    }
                }
                list[i].status = STATUS_READY;
            }
            sw.stop();

            if (log.isDebugEnabled()) {
                for (int i = 0; i < list.length; i++) {
                    log.debug("Index Complete: " + list[i].indexer.getName());
                }
                log.debug(sw.toString());
            }
        }
    }
View Full Code Here

Examples of org.broadleafcommerce.common.util.StopWatch

    }

    @Override
    public void rebuildIndex() throws ServiceException, IOException {
        LOG.info("Rebuilding the solr index...");
        StopWatch s = new StopWatch();

        // If we are in single core mode, we have to delete the documents before reindexing
        if (SolrContext.isSingleCoreMode()) {
            SolrIndexServiceImpl.this.deleteAllDocuments();
        }

        Object[] pack = saveState();
        try {
            final Long numProducts = productDao.readCountAllActiveProducts();
            if (LOG.isDebugEnabled()) {
                LOG.debug("There are " + numProducts + " total products");
            }
            performCachedOperation(new SolrIndexCachedOperation.CacheOperation() {
                @Override
                public void execute() throws ServiceException {
                    int page = 0;
                    while ((page * pageSize) < numProducts) {
                        buildIncrementalIndex(page, pageSize);
                        page++;
                    }
                }
            });
            optimizeIndex(SolrContext.getReindexServer());
        } finally {
            restoreState(pack);
        }

        // Swap the active and the reindex cores
        shs.swapActiveCores();

        // If we are not in single core mode, we delete the documents for the unused core after swapping
        if (!SolrContext.isSingleCoreMode()) {
            deleteAllDocuments();
        }

        LOG.info(String.format("Finished building index in %s", s.toLapString()));
    }
View Full Code Here

Examples of org.codemap.util.StopWatch

            byte[] shoreColor = colorScheme().getShoreColor().asByte();
           
            int shorelineHeight = map.get(SHORELINE_HEIGHT);
            int hillineHeight = map.get(HILLLINE_HEIGHT);
           
            StopWatch nnStopWatch = new StopWatch("nearest neighbor (total)");
            for(int i=0; i < mapSize*mapSize; i++) {
                int y = i / mapSize;
                int x = i % mapSize;
               
                if (DEM[x][y] <= shorelineHeight) {
                    // water color
                    System.arraycopy(waterColor, 0, imageBytes, i*3, 3);
                    alphaBytes[i] = (byte) 255;
                    continue;
                } else if (DEM[x][y] <= hillineHeight) {
                    // shore colors
                    System.arraycopy(shoreColor, 0, imageBytes, i*3, 3);
                    alphaBytes[i] = (byte) 255;
                    continue;
                }
                // get color from location a.k.a. hill colors
                nnStopWatch.start();
                Location nearestNeighbor = map.nearestNeighbor(x, y);
                MColor mcolor;
                if (nearestNeighbor == null) {
                    mcolor = colorScheme().getHillColor();
                } else {
                    mcolor = colors.forLocation(nearestNeighbor.getPoint());                   
                }
                nnStopWatch.stop();
                // make rgb
                int baseIndex = i*3;
                imageBytes[baseIndex++] = (byte) mcolor.getRed(); // R
                imageBytes[baseIndex++] = (byte) mcolor.getGreen(); // G
                imageBytes[baseIndex++] = (byte) mcolor.getBlue(); // B
               
                // make alpha
                // 0 for fully transparent
                // 255 for fully opaque
                double f = shade[x][y];
                assert f <=1;
                // alpha values can get negative somehow so we fix that
                int alpha = (int) Math.max(0.0, 255*f);
                alphaBytes[i] = (byte) alpha;
            }
            nnStopWatch.print();
            // define a direct palette with masks for RGB
            PaletteData palette = new PaletteData(0xFF0000 , 0xFF00 , 0xFF);  
            ImageData imageData = new ImageData(mapSize, mapSize, 24, palette, mapSize*3, imageBytes);
            // enable alpha by setting alphabytes ... strange that i can't do that per pixel using 32bit values
            imageData.alphaData = alphaBytes;
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.