Example usage for com.google.common.base Stopwatch createStarted

List of usage examples for com.google.common.base Stopwatch createStarted

Introduction

In this page you can find the example usage for com.google.common.base Stopwatch createStarted.

Prototype

@CheckReturnValue
public static Stopwatch createStarted() 

Source Link

Document

Creates (and starts) a new stopwatch using System#nanoTime as its time source.

Usage

From source file:benchmarkio.benchmark.ConsumerOnly.java

@Override
public void run(final MessageConsumerCoordinator messageConsumerCoordinator,
        final MessageProducerCoordinator messageProducerCoordinator, final int numConsumers,
        final int numProducers, final long totalNumberOfMessages, final Report report) {
    final CompletionService<Histogram> consumerCompletionService = messageConsumerCoordinator.startConsumers();

    // Note that the timer is started after startConsumers(), this is by purpose to exclude the initialization time.
    final Stopwatch consumerStartTime = Stopwatch.createStarted();

    report.aggregateAndPrintResults(CoordinatorType.CONSUMER, consumerCompletionService, numConsumers,
            totalNumberOfMessages, consumerStartTime);
}

From source file:org.zalando.zmon.actuator.ZmonRestResponseFilter.java

@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
        final ClientHttpRequestExecution execution) throws IOException {

    Stopwatch stopwatch = Stopwatch.createStarted();
    ClientHttpResponse response = execution.execute(request, body);
    stopwatch.stop();/*from   w  w  w  . j  a  v a 2 s. c  om*/
    metricsWrapper.recordBackendRoundTripMetrics(request, response, stopwatch);
    return response;
}

From source file:dk.dma.nogoservice.controller.ApiController.java

@PostMapping(value = "/area")
@ApiOperation(value = "Get NoGo area", notes = "Returns structured data for all the NoGo polygons. If time is included the tidal information will be included in the NoGo calculation.")
public NoGoResponse getNoGoAreas(@Valid @RequestBody NoGoRequest request) {
    Stopwatch timer = Stopwatch.createStarted();
    NoGoResponse noGoAreas = noGoService.getNoGoAreas(request);
    log.info("NoGo request processed in {} ms", timer.stop().elapsed(TimeUnit.MILLISECONDS));
    return noGoAreas;

}

From source file:es.usc.citius.composit.core.matcher.graph.HashMatchGraph.java

public HashMatchGraph(SetMatchFunction<E, T> setMatcher, Set<E> elements) {
    Stopwatch w = Stopwatch.createStarted();
    logger.debug("Processing full match of {} elements...", elements.size());
    this.matchTable = setMatcher.fullMatch(elements, elements);
    this.elements = elements;
    logger.debug("Match processing finished in {}.", w.stop().toString());
}

From source file:pt.ua.ri.behaviour.SearchBehaviour.java

@Override
public void action() {
    for (String query : queries) {
        Stopwatch sw = Stopwatch.createStarted();

        Iterable<Result> results = s.search(query);
        sw.stop();/*from w  w  w.j a v a  2 s  .c  om*/
        logger.info("Results for: {} ( {} )", query, sw);
        int i = 0;
        logger.info("%8s | %-30s | %10s\n", "#", "Score", "Document");
        for (Result r : results) {
            if (i >= 20) {
                break;
            }
            logger.info("%8d | %-30s | %9.5f%%\n", ++i, idx.getDocumentName(r.getDocId()),
                    r.getScore() * 100.0f);
        }
    }
}

From source file:com.rptools.name.NameGen.java

@Autowired
public NameGen(NameFileParser nameFileParser) {
    Stopwatch timer = Stopwatch.createStarted();
    first = nameFileParser.parseFile("names.txt");
    last = nameFileParser.parseFile("lastNames.txt");
    timer.stop();/* ww w. j  a  v  a2s.c o  m*/
    log.info(String.format(PARSED_TIME, timer.elapsed(TimeUnit.MILLISECONDS)));
}

From source file:com.facebook.buck.distributed.DistBuildSlaveTimingStatsTracker.java

public void startTimer(SlaveEvents event) {
    Preconditions.checkState(!watches.containsKey(event), "Stopwatch for %s has already been started.", event);
    watches.put(event, Stopwatch.createStarted());
}

From source file:com.b2international.commons.ConsoleProgressMonitor.java

@Override
public void beginTask(final String name, final int totalWork) {
    overallProcessTime = Stopwatch.createStarted();
    this.name = name;
    work = 0;//  w  w  w.java 2  s  .  co m
    percent = 0;
    this.totalWork = totalWork;
    time = System.nanoTime();
    logWork(0, false);
}

From source file:qa.qcri.nadeef.core.pipeline.ViolationExport.java

/**
 * Export the violation into database./* w  w w.j  a va2 s  . c  om*/
 *
 * @param violations violations.
 * @return whether the exporting is successful or not.
 */
@Override
public Collection<Violation> execute(Collection<Violation> violations) throws Exception {
    Stopwatch stopwatch = Stopwatch.createStarted();
    Connection conn = null;
    PreparedStatement stat = null;
    DBConnectionPool connectionPool = getCurrentContext().getConnectionPool();
    int count = 0;
    try {
        synchronized (ViolationExport.class) {
            // TODO: this is not out-of-process safe.
            int vid = Violations.generateViolationId(connectionPool);

            conn = connectionPool.getNadeefConnection();
            stat = conn.prepareStatement("INSERT INTO VIOLATION VALUES (?, ?, ?, ?, ?, ?)");

            for (Violation violation : violations) {
                count++;
                Collection<Cell> cells = violation.getCells();
                for (Cell cell : cells) {
                    // skip the tuple id
                    if (cell.hasColumnName("tid")) {
                        continue;
                    }
                    stat.setInt(1, vid);
                    stat.setString(2, violation.getRuleId());
                    stat.setString(3, cell.getColumn().getTableName());
                    stat.setInt(4, cell.getTid());
                    stat.setString(5, cell.getColumn().getColumnName());
                    Object value = cell.getValue();
                    if (value == null) {
                        stat.setString(6, null);
                    } else {
                        stat.setString(6, value.toString());
                    }
                    stat.addBatch();
                }

                if (count % 4096 == 0) {
                    stat.executeBatch();
                }
                vid++;
            }
            setPercentage(0.5f);
            stat.executeBatch();
            conn.commit();
        }

        PerfReport.appendMetric(PerfReport.Metric.ViolationExportTime,
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        PerfReport.appendMetric(PerfReport.Metric.ViolationExport, count);
        stopwatch.stop();
    } finally {
        if (stat != null) {
            stat.close();
        }
        if (conn != null) {
            conn.close();
        }
    }
    return violations;
}

From source file:org.factcast.store.pgsql.internal.catchup.PgCatchUpFetchPage.java

public LinkedList<Fact> fetchFacts(@NonNull AtomicLong serial) {
    Stopwatch sw = Stopwatch.createStarted();
    final LinkedList<Fact> list = new LinkedList<>(jdbc.query(PgConstants.SELECT_FACT_FROM_CATCHUP,
            createSetter(serial, pageSize), new PgFactExtractor(serial)));
    sw.stop();/*w w  w  .  j  a  v a 2  s .  co m*/
    log.debug("{}  fetched next page of Facts for cid={}, limit={}, ser>{} in {}ms", req, clientId, pageSize,
            serial.get(), sw.elapsed(TimeUnit.MILLISECONDS));
    return list;
}