Example usage for org.springframework.util StopWatch stop

List of usage examples for org.springframework.util StopWatch stop

Introduction

In this page you can find the example usage for org.springframework.util StopWatch stop.

Prototype

public void stop() throws IllegalStateException 

Source Link

Document

Stop the current task.

Usage

From source file:com.baocy.tut3.Tut3Receiver.java

public void receive(String in, int receiver) throws InterruptedException {
    StopWatch watch = new StopWatch();
    watch.start();/* ww  w. ja va 2  s.co m*/
    System.out.println("instance " + receiver + " [x] Received '" + in + "'");
    doWork(in);
    watch.stop();
    System.out.println("instance " + receiver + " [x] Done in " + watch.getTotalTimeSeconds() + "s");
}

From source file:org.arrow.test.SpringWorkflowTestExecutionListener.java

@Override
public void afterTestMethod(TestContext testContext) throws Exception {
    CONTEXT_HOLDER.set(null);/*from   ww w .  ja v a  2 s .  co  m*/

    StopWatch stopWatch = (StopWatch) testContext.getAttribute("stopWatch");
    if (stopWatch != null && stopWatch.isRunning()) {
        stopWatch.stop();
        System.out.println(stopWatch);
    }
}

From source file:com.agileapes.webexport.concurrent.Worker.java

@SuppressWarnings("unchecked")
@Override//from ww w .j av a2  s.  c  om
public void run() {
    synchronized (this) {
        while (true) {
            try {
                logger.info("Waiting for a task.");
                wait();
            } catch (InterruptedException e) {
                logger.warn(getName() + " was interrupted.");
                manager.interrupted(this);
                return;
            }
            try {
                final StopWatch watch = new StopWatch();
                watch.start();
                perform();
                watch.stop();
                logger.info("Action performed in " + watch.getTotalTimeMillis() + "ms");
            } catch (Throwable e) {
                logger.error(e);
                manager.fail(this);
            }
            logger.info(getName() + " is done.");
            manager.done(this);
        }
    }
}

From source file:com.baocy.tut2.Tut2Receiver.java

@RabbitHandler
public void receive(String in) throws InterruptedException {
    StopWatch watch = new StopWatch();
    watch.start();//ww w  . j a v  a2  s.c  om
    System.out.println("instance " + this.instance + " [x] Received '" + in + "'");
    doWork(in);
    watch.stop();
    System.out.println("instance " + this.instance + " [x] Done in " + watch.getTotalTimeSeconds() + "s");
}

From source file:org.axonframework.samples.trader.infra.util.ProfilingAspect.java

@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch sw = new StopWatch(getClass().getSimpleName());
    try {//  w  ww.ja v  a2s.c  o m
        sw.start(pjp.getSignature().getName());
        return pjp.proceed();
    } finally {
        sw.stop();
        System.out.println(sw.getLastTaskName() + sw.shortSummary());
    }
}

From source file:com.si.xe.trader.infra.util.ProfilingAspect.java

@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch sw = new StopWatch(getClass().getSimpleName());
    try {/*from ww w  .  j a  va 2  s  .co  m*/
        sw.start(pjp.getSignature().getName());
        return pjp.proceed();
    } finally {
        sw.stop();
        System.out.println(sw.getLastTaskName() + sw.shortSummary());
    }

}

From source file:org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice.java

@Around("aspectjLoadTimeWeavingExamples()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    final Logger logger = LoggerFactory.getLogger(pjp.getSignature().getDeclaringType());

    StopWatch sw = new StopWatch(getClass().getSimpleName());

    try {/*from   w  ww. j av a 2s . c  o  m*/
        sw.start(pjp.getSignature().getName());

        return pjp.proceed();
    } finally {
        sw.stop();

        logger.debug(sw.prettyPrint());
    }
}

From source file:org.focusns.common.web.performance.MonitorFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    ////from ww w .  j a va 2 s . c  om
    if (log.isTraceEnabled()) {
        //
        String requestDesc = getRequestDescription(request);
        StopWatch stopWatch = new StopWatch();
        stopWatch.start(requestDesc);
        //
        filterChain.doFilter(request, response);
        //
        stopWatch.stop();
        //
        log.trace(stopWatch.prettyPrint());
    } else {
        filterChain.doFilter(request, response);
    }
}

From source file:de.uniwue.dmir.heatmap.point.sources.geo.datasources.RTreeGeoDatasource.java

@Override
public void reload() {

    this.rtree.clear();

    StopWatch stopWatch = new StopWatch();
    stopWatch.start("getting data");

    List<TData> data = super.dataSource.getData(null);

    stopWatch.stop();
    super.logger.debug("getting data - count: {}", data.size());
    super.logger.debug("getting data - time: {}", stopWatch.toString());

    stopWatch.start("adding data");

    for (TData s : data) {
        GeoCoordinates geoCoordinates = this.mapper.map(s);
        this.rtree.insert(
                new float[] { (float) geoCoordinates.getLongitude(), (float) geoCoordinates.getLatitude() }, s);
    }/*  www  . ja  va2 s . c o  m*/

    stopWatch.stop();
    super.logger.debug("building r-tree: {}", stopWatch.toString());
}

From source file:org.jsmiparser.SpringTest.java

@Test
public void testPperformance() {
    int times = 10000000;
    StopWatch stopWatch = new StopWatch();
    stopWatch.start("query for " + times + " times");

    for (int i = 0; i < times; i++) {
        getMib().getOidValues().find("snmpOutPkts");
    }/*from   w w w  .  j  a v a  2  s . com*/
    stopWatch.stop();
    System.out.println(stopWatch.prettyPrint());
}