List of usage examples for com.google.common.base Stopwatch Stopwatch
Stopwatch()
From source file:org.icgc.dcc.release.core.util.Stopwatches.java
public static Stopwatch createStarted() { // Can't use the new API here because of dependency conflicts. return new Stopwatch().start(); }
From source file:qa.qcri.qnoise.inject.InconsistencyInjector.java
/** {@inheritDoc */ @Override//from ww w . j a v a 2s . c o m public void act(NoiseContext context, HashMap<String, Object> extras) { Stopwatch stopwatch = new Stopwatch().start(); HashSet<Integer> log = Sets.newHashSet(); NoiseSpec spec = context.spec; DataProfile profile = context.profile; NoiseReport report = context.report; ModelBase indexGen = ModelFactory.createRandomModel(); Constraint[] constraint = spec.constraint; double perc = spec.percentage; // by default, we keep it in the active domain double distances = spec.distance == null ? 0.0 : spec.distance[0]; int[] filteredResult = filter(profile, constraint); int nseed = (int) (Math.ceil(perc * profile.getLength())); int size = Math.min(nseed, filteredResult.length); for (int i = 0; i < size; i++) { int index; do { index = indexGen.nextIndex(0, filteredResult.length); } while (log.contains(index)); log.add(index); int columnIndex = constraint[0].messIt(profile, filteredResult[index], distances, report); // TODO; where is the old value if (columnIndex == -1) { tracer.info("No possible element is found."); } } report.appendMetric(NoiseReport.Metric.ChangedItem, nseed); report.addMetric(NoiseReport.Metric.InjectionTime, stopwatch.elapsed(TimeUnit.MILLISECONDS)); stopwatch.stop(); }
From source file:algores.holonet.core.ProgressSimple.java
public ProgressSimple(final long iterations) { this.stopwatch = new Stopwatch(); this.iterations = iterations; }
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 ww. j a va 2 s . c o m 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:org.caleydo.core.util.clusterer.Clusterers.java
public static ClusterResult cluster(ClusterConfiguration config) { log.info("Started clustering with clusterConfiguration: " + config); Stopwatch w = new Stopwatch().start(); try {// w ww. j ava 2 s . c o m SafeCallable<PerspectiveInitializationData> clusterer = createClusterer(config); if (clusterer == null) { log.error("unknown cluster configuration: " + config); throw new IllegalStateException("Unknown ClusterConfiguration: " + config); } PerspectiveInitializationData data = clusterer.call(); ClusterResult result = new ClusterResult(); switch (config.getClusterTarget()) { case DIMENSION_CLUSTERING: result.setDimensionResult(data); break; case RECORD_CLUSTERING: result.setRecordResult(data); break; } return result; } catch (final Exception e) { log.error("Clustering failed", e); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { MessageBox messageBox = new MessageBox(new Shell(), SWT.ERROR); messageBox.setText("Error"); messageBox.setMessage("A problem occured during clustering!"); messageBox.open(); } }); } }); } finally { log.debug("took: " + w); } return null; }
From source file:org.apache.phoenix.monitoring.MetricsStopWatch.java
MetricsStopWatch(boolean isMetricsEnabled) { this.isMetricsEnabled = isMetricsEnabled; this.stopwatch = new Stopwatch(); }
From source file:co.cask.tigon.internal.app.queue.TimeTrackingQueueReader.java
@Override public final InputDatum<T> dequeue(long timeout, TimeUnit timeoutUnit) throws IOException, InterruptedException { Stopwatch stopwatch = new Stopwatch(); stopwatch.start();/*from www . ja v a 2s .co m*/ long sleepNano = computeSleepNano(timeout, timeoutUnit); long timeoutNano = timeoutUnit.toNanos(timeout); InputDatum<T> result = tryDequeue(timeout, timeoutUnit); while (!result.needProcess()) { if (timeoutNano <= 0) { break; } long elapsedNano = stopwatch.elapsedTime(TimeUnit.NANOSECONDS); if (elapsedNano + sleepNano >= timeoutNano) { break; } TimeUnit.NANOSECONDS.sleep(sleepNano); result = tryDequeue(timeoutNano - elapsedNano, TimeUnit.NANOSECONDS); } return result; }
From source file:org.eclipse.emf.compare.tests.performance.EMFComparePerfStats.java
EMFComparePerfStats() { fMemoryBean = ManagementFactory.getMemoryMXBean(); elapsedTimeInMatch = new Stopwatch(); elapsedTimeInDiff = new Stopwatch(); }
From source file:co.cask.cdap.test.AbstractAdapterManager.java
@Override public void waitForStatus(String runId, ProgramRunStatus status, long timeout, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException { RunRecord runRecord = getRun(runId); // Min sleep time is 10ms, max sleep time is 1 seconds long sleepMillis = getSleepTime(timeout, timeoutUnit); Stopwatch stopwatch = new Stopwatch().start(); while (runRecord.getStatus() != status && stopwatch.elapsedTime(timeoutUnit) < timeout) { TimeUnit.MILLISECONDS.sleep(sleepMillis); runRecord = getRun(runId);/*from w w w . ja v a 2 s.c o m*/ } if (runRecord.getStatus() != status) { throw new TimeoutException("Time limit reached."); } }
From source file:org.kududb.client.DeadlineTracker.java
/** * Creates a new tracker, which starts the stopwatch right now. */ public DeadlineTracker() { this(new Stopwatch()); }