List of usage examples for com.google.common.base Stopwatch createStarted
@CheckReturnValue public static Stopwatch createStarted()
From source file:eu.amidst.core.utils.BayesianNetworkSampler.java
public static void main(String[] args) throws Exception { Stopwatch watch = Stopwatch.createStarted(); BayesianNetwork network = BayesianNetworkLoader.loadFromFile("./networks/dataWeka/asia.bn"); BayesianNetworkSampler sampler = new BayesianNetworkSampler(network); sampler.setSeed(0);//from w ww .j av a 2 s. co m DataStream<DataInstance> dataStream = sampler.sampleToDataStream(100); DataStreamWriter.writeDataToFile(dataStream, "./datasets/simulated/asisa-samples.arff"); System.out.println(watch.stop()); for (Assignment assignment : sampler.getSampleIterator(10)) { System.out.println(assignment.outputString()); } System.out.println(); for (Assignment assignment : sampler.getSampleList(2)) { System.out.println(assignment.outputString()); } System.out.println(); sampler.getSampleStream(2).forEach(e -> System.out.println(e.outputString())); }
From source file:org.asoem.greyfish.utils.collect.UnrolledListAT.java
protected static <T> long measureFindFirstIterative(final List<T> list, final Iterable<? extends Predicate<? super T>> predicates) { final Stopwatch stopwatch = Stopwatch.createStarted(); for (Predicate<? super T> predicate : predicates) { findFirstIterative(list, predicate); }//from w w w . j a v a 2 s . c o m return stopwatch.elapsed(TimeUnit.MICROSECONDS); }
From source file:org.apache.jackrabbit.oak.plugins.backup.FileStoreRestore.java
public static void restore(File source, File destination) throws IOException { if (!validFileStore(source)) { throw new IOException("Folder " + source + " is not a valid FileStore directory"); }/*from w ww .ja va2s . c o m*/ FileStore restore = FileStore.builder(source).buildReadOnly(); Stopwatch watch = Stopwatch.createStarted(); FileStore store = FileStore.builder(destination).build(); SegmentNodeState current = store.getHead(); try { Compactor compactor = new Compactor(store.getTracker()); compactor.setDeepCheckLargeBinaries(true); SegmentNodeState after = compactor.compact(current, restore.getHead(), current); store.setHead(current, after); } finally { restore.close(); store.close(); } watch.stop(); log.info("Restore finished in {}.", watch); }
From source file:org.apache.jackrabbit.oak.plugins.backup.FileStoreBackup.java
public static void backup(NodeStore store, File destination) throws IOException { checkArgument(store instanceof SegmentNodeStore); Stopwatch watch = Stopwatch.createStarted(); NodeState current = ((SegmentNodeStore) store).getSuperRoot(); FileStore.Builder builder = FileStore.builder(destination).withDefaultMemoryMapping(); if (USE_FAKE_BLOBSTORE) { builder.withBlobStore(new BasicReadOnlyBlobStore()); }//from ww w . ja v a 2 s. c om FileStore backup = builder.build(); try { SegmentNodeState state = backup.getHead(); Compactor compactor = new Compactor(backup.getTracker()); compactor.setDeepCheckLargeBinaries(true); compactor.setContentEqualityCheck(true); SegmentNodeState after = compactor.compact(state, current, state); backup.setHead(state, after); } finally { backup.close(); } watch.stop(); log.info("Backup finished in {}.", watch); }
From source file:ch.ethz.tik.hrouting.providers.GraphProvider.java
public static Graph loadGraphFromAssets(Context context) { startedInit = true;/*from w w w. j a v a 2 s . co m*/ Stopwatch stopwatch = Stopwatch.createStarted(); graph = GraphSerializerUtil.deSerialize(getBufferedInputStream(context)); stopwatch.elapsed(TimeUnit.MILLISECONDS); Log.i(TAG, "Deserialized graph in " + stopwatch); return graph; }
From source file:com.spotify.heroic.metric.BackendKeySet.java
public static Collector<BackendKeySet, BackendKeySet> collect(final QueryTrace.Identifier what) { final Stopwatch w = Stopwatch.createStarted(); return results -> { final List<BackendKey> result = new ArrayList<>(); final List<QueryTrace> children = new ArrayList<>(); for (final BackendKeySet r : results) { result.addAll(r.getKeys());/*w ww . j ava 2s .c o m*/ r.trace.ifPresent(children::add); } final Optional<QueryTrace> trace; if (!children.isEmpty()) { trace = Optional .of(new QueryTrace(what, w.elapsed(TimeUnit.NANOSECONDS), ImmutableList.copyOf(children))); } else { trace = Optional.empty(); } return new BackendKeySet(result, trace); }; }
From source file:com.christophbonitz.concurrent.Main.java
/** * Run with baseActorCount incrementors and decremntors, as well as 10*baseActorCount readers. * Each will perform actionsPerActor actions. * @param baseActorCount/*from w w w.j a v a2 s .c o m*/ * @param actionsPerActor * @param pool * @param counter * @return time used in milliseconds. */ private static long time(int baseActorCount, int actionsPerActor, ExecutorService pool, Counter counter) { Stopwatch sw = Stopwatch.createStarted(); CounterExecutor counterExecutor = new CounterExecutor(pool, counter, 10 * baseActorCount, baseActorCount, baseActorCount, actionsPerActor); counterExecutor.run(); sw.stop(); return sw.elapsed(TimeUnit.MILLISECONDS); }
From source file:com.hortonworks.streamline.common.util.ParallelStreamUtil.java
public static void runAsync(Callable<Void> callable, Executor executor) { Stopwatch stopwatch = Stopwatch.createStarted(); LOG.debug("runAsync start"); CompletableFuture<Void> res = CompletableFuture.supplyAsync(() -> { try {/*from w w w . j a v a 2 s .c o m*/ return callable.call(); } catch (Exception ex) { throw new RuntimeException(ex); } }, executor); res.whenComplete((r, th) -> { // LOG any exceptions if (th != null) { LOG.error("Got exception while running async task", th.getCause()); } LOG.debug("runAsync complete - elapsed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); stopwatch.stop(); }); }
From source file:com.googlesource.gerrit.plugins.auditsl4j.WaitForCondition.java
public default boolean waitFor(Supplier<Boolean> condition) { Stopwatch stopwatch = Stopwatch.createStarted(); try {//from ww w . ja va2s.co m Duration maxWait = waitTimeout(); Duration sleep = waitInterval(); boolean conditionSucceeded = condition.get(); while (!conditionSucceeded && stopwatch.elapsed().compareTo(maxWait) < 0) { try { Thread.sleep(sleep.toMillis()); } catch (InterruptedException e) { } conditionSucceeded = condition.get(); } return conditionSucceeded; } finally { stopwatch.stop(); } }
From source file:org.testeditor.fixture.host.util.Timer.java
public void startTimer() { sw = Stopwatch.createStarted(); }