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

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

Introduction

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

Prototype

public Stopwatch stop() 

Source Link

Document

Stops the stopwatch.

Usage

From source file:com.google.android.marvin.utils.TraceAspect.java

@Around("methodAnnotatedWithDebugTrace() " + "|| talkbackAllMethods()  "
        + "||  constructorAnnotatedDebugTrace()")
public Object weaveJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
    final Stopwatch stopWatch = new Stopwatch();
    stopWatch.start();/*from   w  w w .j  a v a  2s  .  c  o  m*/
    callLevel++;
    Object result = joinPoint.proceed();
    stopWatch.stop();
    log(joinPoint, stopWatch.elapsedMillis());
    callLevel--;
    return result;
}

From source file:org.geoserver.jdbcconfig.JDBCGeoServerLoader.java

@Override
protected void loadCatalog(Catalog catalog, XStreamPersister xp) throws Exception {
    if (!config.isEnabled()) {
        super.loadCatalog(catalog, xp);
        return;//w w w .  j  ava2 s  .c  om
    }

    Stopwatch sw = new Stopwatch().start();
    loadCatalogInternal(catalog, xp);
    sw.stop();
    //System.err.println("Loaded catalog in " + sw.toString());
}

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

public void stopTimer(SlaveEvents event) {
    Stopwatch watch = Preconditions.checkNotNull(watches.get(event));
    Preconditions.checkState(watch.isRunning(), "Stopwatch for %s has already been stopped.", event);
    watch.stop();
}

From source file:org.lenskit.cli.commands.TrainModel.java

@Override
public void execute(Namespace opts) throws IOException, RecommenderBuildException {
    Context ctx = new Context(opts);
    LenskitConfiguration dataConfig = ctx.input.getConfiguration();
    LenskitRecommenderEngineBuilder builder = LenskitRecommenderEngine.newBuilder();
    for (LenskitConfiguration config : ctx.environment.loadConfigurations(ctx.getConfigFiles())) {
        builder.addConfiguration(config);
    }//from www  .  j  ava  2s  . c om
    builder.addConfiguration(dataConfig, ModelDisposition.EXCLUDED);

    Stopwatch timer = Stopwatch.createStarted();
    LenskitRecommenderEngine engine = builder.build();
    timer.stop();
    logger.info("built model in {}", timer);
    File output = ctx.getOutputFile();
    CompressionMode comp = CompressionMode.autodetect(output);

    logger.info("writing model to {}", output);
    try (OutputStream raw = new FileOutputStream(output); OutputStream stream = comp.wrapOutput(raw)) {
        engine.write(stream);
    }
}

From source file:io.flutter.run.daemon.FlutterAppListener.java

@Override
public void onAppProgressFinished(@NotNull DaemonEvent.AppProgress event) {
    progress.done();/*ww  w  . j  a  v a  2  s  .  c o m*/
    final Stopwatch watch = stopwatch.getAndSet(null);
    if (watch != null) {
        watch.stop();
        switch (event.getType()) {
        case "hot.reload":
            reportElapsed(watch, "Reloaded", "reload");
            break;
        case "hot.restart":
            reportElapsed(watch, "Restarted", "restart");
            break;
        }
    }
}

From source file:com.facebook.buck.distributed.build_slave.BuildSlaveTimingStatsTracker.java

public synchronized void stopTimer(SlaveEvents event) {
    Stopwatch watch = Objects.requireNonNull(watches.get(event));
    Preconditions.checkState(watch.isRunning(), "Stopwatch for %s has already been stopped.", event);
    watch.stop();
}

From source file:benchmarkio.producer.kafka.KafkaMessageProducer.java

private void produce(final String topic, final String message) {
    for (int i = 0; i < numberOfMessagesToProduce; i++) {
        try {//w ww  .ja  v a  2  s . co m
            if (log.isDebugEnabled()) {
                log.debug("Publishing message to Kafka topic {}\n{}", topic, message.toString());
            }

            final KeyedMessage<String, String> data = new KeyedMessage<>(topic, message);

            // Start
            final Stopwatch stopwatch = Stopwatch.createStarted();

            producer.send(data);

            // End
            stopwatch.stop();
            histogram.recordValue(stopwatch.elapsed(Consts.TIME_UNIT_FOR_REPORTING));

        } catch (final Exception e) {
            log.error("Error publishing message to kafka topic {}\n{}", topic, message.toString());
        }
    }

    log.info("Finished production of {} messages", numberOfMessagesToProduce);
}

From source file:nl.knaw.huygens.timbuctoo.tools.process.Pipeline.java

@Override
public void call() throws Exception {
    Stopwatch stopWatch = Stopwatch.createStarted();
    for (Task task : tasks) {
        LOG.info(task.getDescription());
        task.call();//from   w  w  w.j  a v a 2  s  . co  m
    }
    stopWatch.stop();
    LOG.info("Time used: {}", stopWatch);
}

From source file:org.apache.hadoop.hive.util.ElapsedTimeLoggingWrapper.java

public T invoke(String message, Logger LOG, boolean toStdErr) throws Exception {
    Stopwatch sw = new Stopwatch().start();
    try {/*w  w  w .jav  a 2  s  .com*/
        T retVal = invokeInternal();
        return retVal;
    } finally {
        String logMessage = message + " ElapsedTime(ms)=" + sw.stop().elapsed(TimeUnit.MILLISECONDS);
        LOG.info(logMessage);
        if (toStdErr) {
            System.err.println(logMessage);
        }
    }
}

From source file:pro.foundev.strategies.BenchmarkStrategy.java

private void exec(Runnable runnable, String name, int runs, BenchmarkReport report) {
    logger.info("Starting run of " + name);
    DescriptiveStatistics stats = new DescriptiveStatistics();

    Stopwatch timer = new Stopwatch();
    for (int i = 0; i < runs; i++) {
        timer.start();/*w w w .j av a 2 s  .  co m*/
        runnable.run();
        timer.stop();
        logger.info("Time to execute load run #" + i + " it took " + timer);
        stats.addValue(timer.elapsed(TimeUnit.MILLISECONDS));
        timer.reset();
    }
    logger.info("Finished run of " + name);
    report.addLine(name, stats.getMin(), stats.getMax(), stats.getPercentile(50), stats.getPercentile(90),
            stats.getMean());
}