List of usage examples for com.google.common.base Stopwatch createUnstarted
@CheckReturnValue public static Stopwatch createUnstarted()
From source file:org.smartdeveloperhub.vocabulary.publisher.handlers.ProbeHandler.java
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final Stopwatch watch = Stopwatch.createUnstarted(); MoreAttachments.setStopwatch(exchange, watch); watch.start();/*from w ww .j a v a 2 s . c o m*/ this.next.handleRequest(exchange); }
From source file:org.sonatype.sisu.bl.testsupport.DropwizardITSupport.java
protected static Stopwatch startBundle(final DropwizardBundle bundle) { final Stopwatch stopwatch = Stopwatch.createUnstarted(); if (bundle != null && !bundle.isRunning()) { stopwatch.start();/* w w w.j a v a 2 s. c o m*/ try { log.info("Starting DropWizard bundle ({})", bundle); bundle.start(); } catch (Exception e) { throw Throwables.propagate(e); } stopwatch.stop(); } return stopwatch; }
From source file:org.smartdeveloperhub.vocabulary.language.lexvo.Chronographer.java
Chronographer(final String taskName) { this.taskName = taskName; this.unit = TimeUnit.MILLISECONDS; this.startedMessage = ""; this.stopwatch = Stopwatch.createUnstarted(); }
From source file:org.smartdeveloperhub.curator.connector.LoggedConnectorFuture.java
LoggedConnectorFuture(final ConnectorFuture delegate) { this.delegate = delegate; this.completion = Stopwatch.createUnstarted(); }
From source file:net.conquiris.search.DefaultManagedReaderSupplier.java
/** * Constructor.//from w ww . j av a 2 s . c om * @param source Reader supplier to manage. * @param holdTime Reader hold time (ms). If negative, zero will be used. */ DefaultManagedReaderSupplier(ReaderSupplier source, long holdTime) { this.source = checkNotNull(source, "The unmanaged reader source must be provided"); this.holdTime = Math.max(0, holdTime); this.watch = this.holdTime > 0 ? Stopwatch.createUnstarted() : null; }
From source file:edu.uci.jforests.input.BinaryFileGenerator.java
public BinaryFileGenerator(String textFile, String featuresStatFile, String binFile) { this.textFile = textFile; this.featuresStatFile = featuresStatFile; this.binFile = binFile; timer = new java.util.Timer(); stopwatch = Stopwatch.createUnstarted(); }
From source file:com.arpnetworking.tsdaggregator.perf.FilePerfTestBase.java
/** * Runs a test.// w w w . j a v a 2 s .c o m * * @param pipelineConfigurationFile Pipeline configuration file. * @param duration Timeout period. */ protected void benchmark(final File pipelineConfigurationFile, final Duration duration) { LOGGER.debug(String.format("Launching pipeline; configuration=%s", pipelineConfigurationFile)); // Create custom "canary" sink final CountDownLatch latch = new CountDownLatch(1); final Stopwatch timer = Stopwatch.createUnstarted(); final ListeningSink sink = new ListeningSink(new Function<Collection<AggregatedData>, Void>() { @Nullable @Override public Void apply(@Nullable final Collection<AggregatedData> input) { if (input != null) { final AggregatedData datum = Iterables.getFirst(input, null); if (datum != null && TestFileGenerator.CANARY.equals(datum.getFQDSN().getMetric()) && timer.isRunning()) { timer.stop(); latch.countDown(); } } return null; } }); // Load the specified stock configuration final PipelineConfiguration stockPipelineConfiguration = new StaticConfiguration.Builder() .addSource(new JsonNodeFileSource.Builder().setFile(pipelineConfigurationFile).build()) .setObjectMapper(PipelineConfiguration.createObjectMapper(_injector)).build() .getRequiredAs(PipelineConfiguration.class); // Add the custom "canary" sink final List<Sink> benchmarkSinks = Lists.newArrayList(stockPipelineConfiguration.getSinks()); benchmarkSinks.add(sink); // Create the custom configuration final PipelineConfiguration benchmarkPipelineConfiguration = OvalBuilder.<PipelineConfiguration, PipelineConfiguration.Builder>clone( stockPipelineConfiguration).setSinks(benchmarkSinks).build(); // Instantiate the pipeline final Pipeline pipeline = new Pipeline(benchmarkPipelineConfiguration); // Execute the pipeline until the canary flies the coop try { timer.start(); pipeline.launch(); if (!latch.await(duration.getMillis(), TimeUnit.MILLISECONDS)) { LOGGER.error("Test timed out"); throw new RuntimeException("Test timed out"); } } catch (final InterruptedException e) { Thread.interrupted(); throw new RuntimeException("Test interrupted"); } finally { pipeline.shutdown(); } }
From source file:org.opendaylight.bgpcep.pcep.topology.provider.SessionListenerState.java
public SessionListenerState() { this.sessionUpDuration = Stopwatch.createUnstarted(); this.capa = new PeerCapabilities(); }
From source file:com.google.cloud.genomics.gatk.htsjdk.GA4GHSamRecordIterator.java
public GA4GHSamRecordIterator(GenomicsDataSource<Read, ReadGroupSet, Reference> dataSource, String readSetId, GA4GHQueryInterval[] intervals) { this.dataSource = dataSource; this.readSetId = readSetId; this.intervals = intervals; this.timer = Stopwatch.createUnstarted(); seekMatchingRead();/*from w ww . j av a 2 s . c o m*/ }
From source file:be.nbb.cli.util.BasicCliLauncher.java
public void launch(@Nonnull String[] args) { ArgsParser<T> parser = parserSupplier.get(); T params = null;// w ww.jav a 2s . c o m try { params = parser.parse(args); } catch (IllegalArgumentException ex) { System.err.println(ex.getMessage()); System.exit(-1); } StandardOptions so = toSo.apply(params); if (so.isShowHelp()) { printHelp(System.out, parser); System.exit(0); } if (so.isShowVersion()) { printVersion(System.out, commandSupplier.get()); System.exit(0); } try { Stopwatch stopwatch = Stopwatch.createUnstarted(); if (so.isVerbose()) { printParams(params, System.err); stopwatch.start(); } commandSupplier.get().exec(params); if (so.isVerbose()) { System.err.println("Executed in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms"); } } catch (Exception ex) { if (so.isVerbose()) { ex.printStackTrace(System.err); } else { System.err.println(ex.getMessage()); } System.exit(-1); } }