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.couchbase.roadrunner.workloads.GetsCasWorkload.java

private long getsWorkloadWithMeasurement(String key) {
    Stopwatch watch = new Stopwatch().start();
    long cas = getsWorkload(key);
    watch.stop();
    addMeasure("gets", watch);
    return cas;/*from   w w  w.j  a v  a  2  s.  c o m*/
}

From source file:org.apache.distributedlog.service.StatsFilter.java

@Override
public Future<Rep> apply(Req req, Service<Req, Rep> service) {
    Future<Rep> result = null;
    outstandingAsync.inc();//from   w w w .  j av  a 2s  . com
    final Stopwatch stopwatch = Stopwatch.createStarted();
    try {
        result = service.apply(req);
        serviceExec.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS));
    } finally {
        outstandingAsync.dec();
        if (null == result) {
            serviceExec.registerFailedEvent(stopwatch.stop().elapsed(TimeUnit.MICROSECONDS));
        }
    }
    return result;
}

From source file:org.locationtech.geogig.rest.repository.SendObjectResource.java

@Override
public void post(Representation entity) {
    InputStream input = null;/*from ww w .jav  a2s .c  o m*/

    Request request = getRequest();
    try {
        LOGGER.info("Receiving objects from {}", request.getClientInfo().getAddress());
        Representation representation = request.getEntity();
        input = representation.getStream();
        final GeoGIG ggit = getGeogig(request).get();
        final BinaryPackedObjects unpacker = new BinaryPackedObjects(ggit.getRepository().objectDatabase());

        CountingInputStream countingStream = new CountingInputStream(input);

        Stopwatch sw = Stopwatch.createStarted();
        IngestResults ingestResults = unpacker.ingest(countingStream);
        sw.stop();

        LOGGER.info(String.format(
                "SendObjectResource: Processed %,d objects.\nInserted: %,d.\nExisting: %,d.\nTime to process: %s.\nStream size: %,d bytes.\n",
                ingestResults.total(), ingestResults.getInserted(), ingestResults.getExisting(), sw,
                countingStream.getCount()));

    } catch (IOException e) {
        LOGGER.warn("Error processing incoming objects from {}", request.getClientInfo().getAddress(), e);
        throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e);
    } finally {
        if (input != null)
            Closeables.closeQuietly(input);
    }
}

From source file:com.vmware.photon.controller.rootscheduler.service.SchedulerService.java

@Override
public PlaceResponse place(PlaceRequest request) throws TException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    PlaceResponse placeResponse = flatSchedulerService.place(request);
    stopwatch.stop();
    logger.info("elapsed-time place {} milliseconds", stopwatch.elapsed(TimeUnit.MILLISECONDS));

    return placeResponse;
}

From source file:org.apache.eagle.alert.coordinator.trigger.ScheduleStateCleaner.java

@Override
public void run() {
    // we should catch every exception to avoid zombile thread
    try {/*from   www.j a  v  a2  s  .  c  o  m*/
        final Stopwatch watch = Stopwatch.createStarted();
        LOG.info("clear schedule states start.");
        client.clearScheduleState(reservedCapacity);
        watch.stop();
        LOG.info("clear schedule states completed. used time milliseconds: {}",
                watch.elapsed(TimeUnit.MILLISECONDS));
        // reset cached policies
    } catch (Throwable t) {
        LOG.error("fail to clear schedule states due to {}, but continue to run", t.getMessage());
    }
}

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: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();
    log.info(String.format(PARSED_TIME, timer.elapsed(TimeUnit.MILLISECONDS)));
}

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

@Override
public void execute() throws IOException, RecommenderBuildException {
    LenskitConfiguration dataConfig = input.getConfiguration();
    LenskitRecommenderEngineBuilder builder = LenskitRecommenderEngine.newBuilder();
    for (LenskitConfiguration config : environment.loadConfigurations(getConfigFiles())) {
        builder.addConfiguration(config);
    }//from   w w  w . j  a  v  a2  s .c  o m
    builder.addConfiguration(dataConfig, ModelDisposition.EXCLUDED);

    Stopwatch timer = Stopwatch.createStarted();
    LenskitRecommenderEngine engine = builder.build();
    timer.stop();
    logger.info("built model in {}", timer);
    File output = getOutputFile();
    logger.info("writing model to {}", output);
    Closer closer = Closer.create();
    try {
        OutputStream stream = closer.register(new FileOutputStream(output));
        if (LKFileUtils.isCompressed(output)) {
            stream = closer.register(new GZIPOutputStream(stream));
        }
        engine.write(stream);
    } catch (Throwable th) {
        throw closer.rethrow(th);
    } finally {
        closer.close();
    }
}

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

@PostMapping(value = "/area/wkt")
@ApiOperation(value = "Get NoGo area as WKT", notes = "Returns a single MultiPolygon with all the nogo areas. If time is included the tidal information will be included in the NoGo calculation.")
public MultiPolygon getNoGoAreasAsWKT(@Valid @RequestBody NoGoRequest request) {
    Stopwatch timer = Stopwatch.createStarted();
    NoGoResponse nogo = noGoService.getNoGoAreas(request);
    log.info("NoGo (wkt) request processed in {} ms", timer.stop().elapsed(TimeUnit.MILLISECONDS));
    return nogo.toMultiPolygon();

}

From source file:org.grouplens.lenskit.eval.EvalTarget.java

@Override
public void execute() throws BuildException {
    try {//from  w w w  .  j  a v a2s.  co  m
        logger.info("beginning execution of {}", getName());
        Stopwatch watch = Stopwatch.createStarted();
        super.execute();
        watch.stop();
        logger.info("{} finished in {}", getName(), watch);
        if (lastTaskFuture != null) {
            if (!lastTaskFuture.isDone()) {
                logger.error("{}: future for task {} did not complete", getName(), lastTask);
                returnValue.setException(new RuntimeException("task future didn't complete"));
            } else {
                while (!returnValue.isDone()) {
                    try {
                        returnValue.set(lastTaskFuture.get());
                    } catch (ExecutionException ex) {
                        returnValue.setException(ex.getCause());
                    } catch (InterruptedException e) {
                        logger.warn("{}: task future get() was interrupted", getName());
                        returnValue.setException(e);
                        throw new BuildException("Build task interrupted", e);
                    }
                }
            }
        } else {
            returnValue.set(null);
        }
    } catch (RuntimeException ex) {
        returnValue.setException(ex);
        throw ex;
    }
}