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

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

Introduction

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

Prototype

public void start() 

Source Link

Document

Start the stopwatch.

This method starts a new timing session, clearing any previous values.

Usage

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   www .ja v  a  2  s  .  c o m*/
    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: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();

    while (iter.hasNext()) {
        String word = iter.next();
        assertTrue("Missing word (" + word + ")", dawgBuilder.contains(word));
    }/*w  ww .  j av  a  2 s. c  o m*/

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

    LineIterator.closeQuietly(iter);
}

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

@Before
public void before() throws IOException {
    assumeThat(System.getProperty("RUN_VALIDATION"), is("on"));
    LineIterator iter = IOUtils.lineIterator(getClass().getResourceAsStream("/TWL06.txt"), null);
    dawgBuilder = new DawgBuilder();

    while (iter.hasNext())
        dawgBuilder.add(iter.next());//  ww  w  .j  a  v a2  s . co m

    LineIterator.closeQuietly(iter);

    System.out.println("Uncompressed:  " + dawgBuilder.nodeCount() + " nodes");

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    dawgBuilder.build();
    stopWatch.stop();

    System.out.println("Time to compress:  " + stopWatch.getTime() + " ms.");
    System.out.println("Compressed:  " + dawgBuilder.nodeCount() + " nodes");
}

From source file:com.liferay.subscription.internal.messaging.SubscriptionSenderMessageListener.java

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

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();

    if (_log.isInfoEnabled()) {
        _log.info("Sending notifications for {mailId=" + subscriptionSender.getMailId() + "}");
    }/*  w  ww  .jav a2s .  c  o  m*/

    subscriptionSender.flushNotifications();

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

From source file:de.unisb.cs.st.javalanche.mutation.util.DBPerformanceTest.java

private void testDelete() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    MutationDeleter.deleteAllWithPrefix(PREFIX);
    stopWatch.stop();/* w  w  w . j  av a 2s .  c o m*/
    System.out.printf("Deleting %d mutations took %s\n", LIMIT,
            DurationFormatUtils.formatDurationHMS(stopWatch.getTime()));
}

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();
    }//  www  . j  a v a2 s.  com
    //log4j.xml???
    log.info(
            "-----------------------------------------------------------------------------");
    log.info("[" + methodName + "(" + StringUtils.join(simpleParams, ",") + ")];:"
            + clock.getTime() + ";[" + fullPath + "]");
    return result;
}

From source file:de.unisb.cs.st.javalanche.mutation.util.DBPerformanceTest.java

private void testInsert() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    QueryManager.saveMutations(getMutations());
    stopWatch.stop();//from   w ww.j av  a2  s  .  c om
    System.out.println("Inserting " + LIMIT + " mutations took "
            + DurationFormatUtils.formatDurationHMS(stopWatch.getTime()));

}

From source file:fr.inria.edelweiss.kgdqp.core.CallableResult.java

@Override
public Result call() {
    StopWatch sw = new StopWatch();
    sw.start();
    Result result = new Result((RemoteProducerWSImpl) producer);

    if (exp.isEdge()) {
        logger.info("CallableResult for GetEdge");
        Iterable<Entity> res = producer.getEdges(gNode, from, exp.getEdge(), env);
        result.setEntities(res);/*from  w  w w  . ja  v  a  2  s  .  c  om*/
    } else {
        logger.info("CallableResult for GetMappings");
        Mappings mappings = producer.getMappings(gNode, from, exp, env);
        RemoteProducerWSImpl rp = (RemoteProducerWSImpl) producer;
        logger.info("RESULTS: " + mappings.size() + " FROM " + rp.getEndpoint().getEndpoint());
        result.setMappings(mappings);
    }
    sw.stop();
    logger.info("Finished CallableResult in " + sw.getTime() + " ms.");
    return result;
}

From source file:au.id.wolfe.stormcloud.core.interceptor.DAOInterceptor.java

@Around("execution(* au.id.wolfe.stormcloud.core.dao..*.*(..))")
public Object logHibernateQueryTimes(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

    final String targetClass = ClassUtils
            .getShortClassName(proceedingJoinPoint.getTarget().getClass().getName());
    final String methodName = proceedingJoinPoint.getSignature().getName();

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();
    Object retVal = proceedingJoinPoint.proceed();
    stopWatch.stop();//www. j a v a  2s  . c o m

    StringBuilder sb = new StringBuilder();
    sb.append(targetClass).append(" - ").append(methodName).append(": ").append(stopWatch.getTime())
            .append(" ms");

    log.debug(sb.toString());

    return retVal;
}

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

/**
 * Creats a triangle mesh for the wind data.
 *
 * @param data as sorted map./*  w  ww. ja  v  a 2s  .  co  m*/
 * @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;
}