Example usage for org.apache.commons.lang3.time StopWatch getSplitTime

List of usage examples for org.apache.commons.lang3.time StopWatch getSplitTime

Introduction

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

Prototype

public long getSplitTime() 

Source Link

Document

Get the split time on the stopwatch.

Usage

From source file:org.jodconverter.PerformanceITest.java

private void convertFileXTimes(final File inputFile, final DocumentFormat inputFormat,
        final DocumentFormat outputFormat) throws IOException, OfficeException {

    final String baseName = FilenameUtils.getBaseName(inputFile.getName());

    long lastSplitTime = 0L;
    final StopWatch stopWatch = new StopWatch();
    stopWatch.start();/*from  www  .  j av a  2 s .c om*/
    for (int i = 0; i < MAX_CONVERSIONS; i++) {
        final File outputFile = File.createTempFile("test", "." + outputFormat.getExtension());
        outputFile.deleteOnExit();

        LOGGER.info(baseName + " -- converting " + inputFormat.getExtension() + " to "
                + outputFormat.getExtension() + "... ");
        LocalConverter.make().convert(inputFile).as(inputFormat).to(outputFile).as(outputFormat).execute();

        stopWatch.split();
        final long splitTime = stopWatch.getSplitTime();
        LOGGER.info(baseName + "-- conversion done in " + (splitTime - lastSplitTime) + " millisec.");
        lastSplitTime = splitTime;
    }
    stopWatch.stop();
    final long conversionTime = stopWatch.getTime();

    LOGGER.info(baseName + "-- all " + MAX_CONVERSIONS + " conversions done in "
            + getDurationBreakdown(conversionTime) + ". The average per document is "
            + (conversionTime / MAX_CONVERSIONS) + " ms.");
}

From source file:org.sparkbit.jsonrpc.JSONRPCController.java

public boolean waitForTxSelectable(Transaction tx) {
    int n = jetty.sendAssetTimeout;
    if (n == 0)//w  ww . j  av a 2 s  .c om
        return true; // don't wait if timeout period is 0

    final StopWatch stopwatch = new StopWatch();
    stopwatch.start();
    boolean timedOut = false;

    while (!DefaultCoinSelector.isSelectable(tx)) {
        try {
            Thread.sleep(WAIT_FOR_TX_SELECTABLE_SLEEP_INTERVAL);
        } catch (InterruptedException e) {
        }
        stopwatch.split();
        long elapsed = stopwatch.getSplitTime();
        stopwatch.unsplit();
        //       log.debug("elapsed = " + elapsed);
        if (elapsed > n) {
            timedOut = true;
            log.debug("Waiting in loop to be selectable timed out for txid " + tx.getHashAsString());
            break; // timed out waiting for tx to be selectable
        }
    }

    stopwatch.stop();
    if (!timedOut) {
        log.debug("Waiting in loop to be selectable took " + stopwatch + " for txid " + tx.getHashAsString()
                + " and broadcast count is " + tx.getConfidence().getBroadcastByCount());
    }

    return true;
}