Package org.apache.commons.lang.time

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


  protected Map<String, BeanDefinition> newBeanDefinitions = CollectUtils.newHashMap();

  protected BindRegistry bindRegistry;

  public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
    StopWatch watch = new StopWatch();
    watch.start();
    bindRegistry = new DefinitionBindRegistry(registry);
    register(registry);
    autowire();
    logger.debug("Auto register and wire bean [{}]", newBeanDefinitions.keySet());
    logger.info("Auto register and wire {} beans using {} mills", newBeanDefinitions.size(),
        watch.getTime());
    newBeanDefinitions.clear();
    bindRegistry = null;
  }
View Full Code Here

@Test
public class AutoConfigProcessorTest {

  public void testGet() {
    StopWatch watch = new StopWatch();
    watch.start();
    ApplicationContext factory = new ClassPathXmlApplicationContext("/context-auto.xml");
    testBean(factory);
    testFactoryBean(factory);
    System.out.println("config  context-auto completed using " + watch.getTime());
  }
View Full Code Here

    testFactoryBean(factory);
    System.out.println("config  context-auto completed using " + watch.getTime());
  }

  public void testNoAutowire() {
    StopWatch watch = new StopWatch();
    watch.start();
    ApplicationContext factory = new ClassPathXmlApplicationContext("/context-auto.xml");
    String name = SomeAction.class.getName();
    for (int i = 0; i < 100; i++) {
      factory.getBean(name);
    }
    System.out.println("no autowire using " + watch.getTime());
  }
View Full Code Here

    response.setHeader("connection", "Keep-Alive");
    int length = 0;
    long start = 0L;
    long begin = 0L;
    long stop = 0L;
    StopWatch watch = new StopWatch();
    watch.start();
    try {
      length = input.available();
      stop = length - 1;
      response.setContentLength(length);
      String rangestr = request.getHeader("Range");
      if (null != rangestr) {
        String[] readlength = StringUtils.substringAfter(rangestr, "bytes=").split("-");
        start = Long.parseLong(readlength[0]);
        if (readlength.length > 1 && StringUtils.isNotEmpty(readlength[1])) {
          stop = Long.parseLong(readlength[1]);
        }
        if (start != 0) {
          response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
          String crange = "bytes " + start + "-" + stop + "/" + length;
          response.setHeader("Content-Range", crange);
        }
      }
      OutputStream output = response.getOutputStream();
      input.skip(start);
      begin = start;
      int size = 4 * 1024;
      byte[] buffer = new byte[size];
      for (int step = maxStep(start, stop, size); step > 0; step = maxStep(start, stop, size)) {
        int readed = input.read(buffer, 0, step);
        if (readed == -1) break;
        output.write(buffer, 0, readed);
        start += readed;
      }
    } catch (IOException e) {
    } catch (Exception e) {
      logger.warn("download file error " + attach, e);
    } finally {
      IOUtils.closeQuietly(input);
      if (logger.isDebugEnabled()) {
        String percent = null;
        if (length == 0) {
          percent = "100%";
        } else {
          percent = ((int) (((start - begin) * 1.0 / length) * 10000)) / 100.0f + "%";
        }
        long time = watch.getTime();
        int rate = 0;
        if (start - begin > 0) {
          rate = (int) (((start - begin) * 1.0 / time * 1000) / 1024);
        }
        logger.debug("{}({}-{}/{}) download {}[{}] in {} ms with {} KB/s",
View Full Code Here

    }
  }

  public void initFrom(SessionFactory sessionFactory) {
    if (null != sessionFactory && entityTypes.isEmpty()) {
      StopWatch watch = new StopWatch();
      watch.start();
      Map<String, ClassMetadata> classMetadatas = sessionFactory.getAllClassMetadata();
      for (Iterator<ClassMetadata> iter = classMetadatas.values().iterator(); iter.hasNext();) {
        ClassMetadata cm = (ClassMetadata) iter.next();
        buildEntityType(sessionFactory, cm.getEntityName());
      }
      logger.info("Find {} entities,{} collections from hibernate in {} ms",
          new Object[] { entityTypes.size(), collectionTypes.size(), watch.getTime() });
      if (logger.isDebugEnabled()) {
        loggerTypeInfo();
      }
      collectionTypes.clear();
    }
View Full Code Here

  }

  @Test(timeOut = 10000)
  public void testPerformance() throws Exception {
    DefaultPropertyExtractor extractor = new DefaultPropertyExtractor();
    StopWatch watch = new StopWatch();
    watch.start();
    for (int i = 0; i < 1000; i++) {
      extract(extractor);
    }
    // System.out.println(watch.getTime());
  }
View Full Code Here

  }

  @Test(timeOut = 1000)
  public void testPerformance2() throws Exception {
    DefaultPropertyExtractor extractor = new DefaultPropertyExtractor();
    StopWatch watch = new StopWatch();
    watch.start();
    for (int i = 0; i < 1000; i++) {
      extract(extractor);
    }
    // System.out.println(watch.getTime());
  }
View Full Code Here

    Map<String, Object> datas = CollectUtils.newHashMap();
    datas.put("b", new BeangleTagLibrary(ActionContext.getContext().getValueStack(),
        new MockHttpServletRequest(), new MockHttpServletResponse()));
    datas.put("s", new StrutsModels(ActionContext.getContext().getValueStack(),
        new MockHttpServletRequest(), new MockHttpServletResponse()));
    datas.put("watch", new StopWatch());
    StringWriter writer = new StringWriter();
    Template template = cfg.getTemplate("comp.ftl");
    // template.process(datas, writer);
  }
View Full Code Here

    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                StopWatch sw = new StopWatch();
                sw.start();
                glassPane.setVisible(true);
                String searchTerm = textField.getText();
                try
                {
                    frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
                    String searchType = null;
                    for (Enumeration<AbstractButton> elements = type
                            .getElements(); elements.hasMoreElements();)
                    {
                        AbstractButton button = elements.nextElement();
                        if (button.isSelected())
                        {
                            searchType = button.getText();
                            break;
                        }
                    }
                    displayPhotos(flickrSearchService.searchPhotos(searchType,
                            searchTerm));
                } catch (Exception e1)
                {
                    e1.printStackTrace();
                } finally
                {
                    frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    frame.pack();
                    center();
                    glassPane.setVisible(false);
                    logger.info(format("finished searching for %s in %d ms",
                            searchTerm, sw.getTime()));
                }
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.time.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.