Example usage for org.apache.commons.lang.time StopWatch StopWatch

List of usage examples for org.apache.commons.lang.time StopWatch StopWatch

Introduction

In this page you can find the example usage for org.apache.commons.lang.time StopWatch StopWatch.

Prototype

public StopWatch() 

Source Link

Document

Constructor.

Usage

From source file:fr.cnrs.sharp.test.MainCLITest.java

@Test
public void Main1() throws IOException {
    InputStream is = MainCLITest.class.getClassLoader().getResourceAsStream("galaxy.prov.ttl");
    Path p = Files.createTempFile("test-prov", ".ttl");
    FileUtils.copyInputStreamToFile(is, p.toFile());
    System.out.println("Galaxy PROV written to " + p.toString());

    String[] params = { "-i", p.toString() };

    StopWatch sw = new StopWatch();
    sw.start();/*from   ww w .  j  av a2s  . c  o m*/
    Main.main(params);
    sw.stop();
    System.out.println("DONE in " + sw.getTime() + " ms");

}

From source file:de.science.hack.meshbuilding.MeshBuilder.java

/**
 * Creats a triangle mesh for the wind data.
 *
 * @param data as sorted map.//from w  w w . ja  va2 s.  c  om
 * @return
 */
public TriangleMesh build(SortedMap<Float, List<Line>> data) {

    TriangleMesh mesh = new WETriangleMesh();
    if (!data.isEmpty()) {
        StopWatch stopWatch = new StopWatch();

        stopWatch.start();
        addFaces(mesh, pool.invoke(new FacesBuilderTask(data)));
        stopWatch.stop();

        LOG.info("constructed mesh in {} ms", stopWatch);
    }
    return mesh;
}

From source file:dataform.components.WorkTimer.java

private void init() throws Exception {
    stopWatch = new StopWatch();
    setEditable(false);//ww w. j  av a2s.c  om

    setForeground(Color.RED);
    setHorizontalAlignment(JLabel.RIGHT);

    setMargin(new Insets(2, 2, 2, 4));
    timer = new javax.swing.Timer(ONE_SECOND, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            timer_ActionPerformed(evt);
        }
    });
    stopWatch.start();
    timer.start();
}

From source file:com.liferay.portal.messaging.SubscriptionSenderMessageListener.java

@Override
protected void doReceive(Message message) throws Exception {
    SubscriptionSender subscriptionSender = (SubscriptionSender) message.getPayload();

    StopWatch stopWatch = null;//from  w  w w  . jav  a2  s  . co  m

    if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();

        _log.info("Sending notifications for {mailId=" + subscriptionSender.getMailId() + "}");
    }

    subscriptionSender.flushNotifications();

    if (_log.isInfoEnabled()) {
        _log.info("Sending notifications for {mailId=" + subscriptionSender.getMailId() + "} completed in "
                + (stopWatch.getTime() / Time.SECOND) + " seconds");
    }
}

From source file:com.icantrap.collections.dawg.DawgValidationTest.java

@Test
public void containsAllWords() throws IOException {
    LineIterator iter = IOUtils.lineIterator(getClass().getResourceAsStream("/TWL06.txt"), null);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();/*from  w  w  w.  j a v a2 s  .  co  m*/

    while (iter.hasNext()) {
        String word = iter.next();
        assertTrue("Missing word (" + word + ")", dawg.contains(word));
    }

    stopWatch.stop();
    System.out.println("Time to query:  " + stopWatch.getTime() + " ms.");

    LineIterator.closeQuietly(iter);
}

From source file:com.hihsoft.sso.sysmonitor.syslogs.aop.LogServiceCallAdvice.java

@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
    final String clazzString = invocation.getThis().getClass().getName();// ??
    final String methodName = invocation.getMethod().getName();// ??
    final String fullPath = clazzString + "." + methodName;
    final StopWatch clock = new StopWatch();
    clock.start(); // 
    final Object result = invocation.proceed();
    clock.stop(); // ? //????

    final Class<?>[] params = invocation.getMethod().getParameterTypes();
    final String[] simpleParams = new String[params.length];
    for (int i = 0; i < params.length; i++) {
        simpleParams[i] = params[i].getSimpleName();
    }//from   w  ww  .java  2  s.  co m
    //log4j.xml???
    log.info(
            "-----------------------------------------------------------------------------");
    log.info("[" + methodName + "(" + StringUtils.join(simpleParams, ",") + ")];:"
            + clock.getTime() + ";[" + fullPath + "]");
    return result;
}

From source file:com.greenline.guahao.web.module.common.interceptor.MethodExecuteTimeInterceptor.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    //  commons-lang ?? StopWatch Spring ?? StopWatch
    StopWatch clock = new StopWatch();
    clock.start(); // 
    Object result = invocation.proceed();
    clock.stop(); // ?

    // ????/*from   ww  w. j  a  va2s  .  com*/
    Class<?>[] params = invocation.getMethod().getParameterTypes();
    String[] simpleParams = new String[params.length];
    for (int i = 0; i < params.length; i++) {
        simpleParams[i] = params[i].getSimpleName();
    }
    logger.info(":" + clock.getTime() + " ms [" + invocation.getThis().getClass().getName()
            + "." + invocation.getMethod().getName() + "(" + StringUtils.join(simpleParams, ",") + ")] ");
    return result;
}

From source file:au.id.hazelwood.xmltvguidebuilder.binding.BindingService.java

public BindingService(String contextPath) throws JAXBException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();// www.j a v  a2s  .  c  om
    JAXBContext jaxbContext = JAXBContext.newInstance(contextPath);
    marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    stopWatch.stop();
    LOGGER.debug("BindingService created for {} in {}", contextPath, formatDurationWords(stopWatch.getTime()));
}

From source file:com.icantrap.collections.dawg.TrieValidationTest.java

@Test
public void containsAllWords() throws IOException {
    LineIterator iter = IOUtils.lineIterator(getClass().getResourceAsStream("/TWL06.txt"), null);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from  www  . ja  v  a  2 s.c om

    while (iter.hasNext()) {
        String word = iter.next();
        assertTrue("Missing word (" + word + ")", dawgBuilder.contains(word));
    }

    stopWatch.stop();
    System.out.println("Time to query:  " + stopWatch.getTime() + " ms.");

    LineIterator.closeQuietly(iter);
}

From source file:com.liferay.calendar.messaging.CalendarHotDeployMessageListener.java

protected void onDeploy(Message message) throws Exception {
    if (!PortletPropsValues.CALENDAR_SYNC_CALEVENTS_ON_STARTUP) {
        return;/* w  ww. jav  a2  s . co m*/
    }

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();

    CalendarImporterLocalServiceUtil.importCalEvents();

    if (_log.isInfoEnabled()) {
        StringBundler sb = new StringBundler(6);

        sb.append("Calendar events synchronization takes ");
        sb.append(stopWatch.getTime());
        sb.append(" ms. Set the property ");
        sb.append("\"calendar.sync.calevents.on.startup\" ");
        sb.append("to \"false\" to disable calendar events ");
        sb.append("synchronization.");

        _log.info(sb.toString());
    }
}