List of usage examples for com.google.common.base Stopwatch elapsed
@CheckReturnValue public long elapsed(TimeUnit desiredUnit)
From source file:com.b2international.snowowl.snomed.reasoner.server.classification.Reasoner.java
private ReasonerTaxonomy computeTaxonomy(final Stopwatch stopwatch) { final ReasonerTaxonomy reasonerTaxonomy = new ReasonerTaxonomy(branchPath, stopwatch.elapsed(TimeUnit.MILLISECONDS)); new ReasonerTaxonomyWalker(branchPath, reasoner, reasonerTaxonomy).walk(); return reasonerTaxonomy; }
From source file:org.glowroot.container.trace.TraceService.java
public @Nullable Trace getActiveTrace(int timeout, TimeUnit unit) throws Exception { Stopwatch stopwatch = Stopwatch.createStarted(); Trace trace = null;//from w w w.j a v a 2 s . com // try at least once (e.g. in case timeoutMillis == 0) boolean first = true; while (first || stopwatch.elapsed(unit) < timeout) { trace = getActiveTrace(); if (trace != null) { break; } Thread.sleep(20); first = false; } return trace; }
From source file:org.rhq.metrics.simulator.MeasurementCollector.java
@Override public void run() { final Timer.Context context = metrics.batchInsertTime.time(); final Stopwatch stopwatch = new Stopwatch().start(); metricsServer.addNumericData(generateData(), new RawDataInsertedCallback() { @Override// ww w.j a v a2s.com public void onFinish() { stopwatch.stop(); log.info("Finished inserting raw data in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms"); context.stop(); } @Override public void onSuccess(MeasurementDataNumeric result) { metrics.rawInserts.mark(); } @Override public void onFailure(Throwable t) { log.warn("Failed to insert raw data", t); } }); }
From source file:org.apache.bookkeeper.proto.ReadEntryProcessorV3.java
protected void registerEvent(boolean failed, OpStatsLogger statsLogger, Stopwatch startTime) { if (failed) { statsLogger.registerFailedEvent(startTime.elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); } else {//from w ww. ja v a2s . c o m statsLogger.registerSuccessfulEvent(startTime.elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); } }
From source file:ch.ge.ve.offlineadmin.controller.BallotDecryptionController.java
private String formatElapsedTime(Stopwatch stopwatch) { long elapsed = stopwatch.elapsed(TimeUnit.SECONDS); long hours = elapsed / 3600; long hourLessElapsed = elapsed % 3600; long minutes = hourLessElapsed / 60; long seconds = hourLessElapsed % 60; return String.format("%d h %02d min %02d sec ", hours, minutes, seconds); }
From source file:org.apache.distributedlog.client.proxy.ProxyClientManager.java
private void notifyHandshakeFailure(SocketAddress address, ProxyClient client, Throwable cause, Stopwatch stopwatch) { handshakeStats.failRequest(address, stopwatch.elapsed(TimeUnit.MICROSECONDS), 1); for (ProxyListener listener : proxyListeners) { listener.onHandshakeFailure(address, client, cause); }/*w w w . j a v a2 s.c om*/ }
From source file:org.zalando.zmon.actuator.metrics.MetricsWrapper.java
public void recordBackendRoundTripMetrics(final HttpRequest request, final ClientHttpResponse response, final Stopwatch stopwatch) { try {//from ww w. j a va 2 s .com submitToTimer( getKey("zmon.backend[" + request.getURI().toString() + "]." + request.getMethod().name().toUpperCase() + "." + response.getStatusCode().toString()), stopwatch.elapsed(TimeUnit.MILLISECONDS)); } catch (IOException e) { logger.warn("Could not detect status for " + response); } }
From source file:com.fireball1725.firelib.FireMod.java
@Mod.EventHandler public final void postInit(FMLPostInitializationEvent event) { final Stopwatch stopwatch = Stopwatch.createStarted(); this.getLogger().info("Post Initialization (Started)"); proxy().postInitStart(event);//from ww w . j a v a2 s .co m proxy().postInitEnd(event); this.getLogger() .info("Post Initialization (Ended after " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms)"); }
From source file:com.minestellar.moon.MinestellarMoon.java
@EventHandler public void init(FMLInitializationEvent event) { Stopwatch stopwatch = Stopwatch.createStarted(); RecipeManagerMoon.loadRecipes();/*from ww w . j a va2s.com*/ this.registerTileEntities(); this.registerCreatures(); this.registerOtherEntities(); MinestellarMoon.proxy.init(event); log.info("Initialization Completed in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms."); }
From source file:joshelser.LimitAndSumColumnFamilyIterator.java
private void setReturnValue(Stopwatch aggrSw) { aggrSw.stop();//from w w w .ja v a 2s . com log.trace("Aggregate duration: " + aggrSw.elapsed(TimeUnit.MILLISECONDS)); if (null != sum) { log.debug("Computed a sum of " + sum); topValue = new Value(encoder.encode(sum)); } else { topValue = new Value(encoder.encode(0l)); } }