List of usage examples for com.google.common.base Stopwatch start
public Stopwatch start()
From source file:ezbake.data.common.LoggingUtils.java
public static void logResetAndStartStopWatch(Logger logger, Stopwatch watch, String name) { watch.stop();/* ww w. j a v a2s .c o m*/ logger.info("{}|{} miliseconds", name, watch.elapsed(TimeUnit.MILLISECONDS)); watch.reset(); watch.start(); }
From source file:processing.BaselineCalculator.java
private static List<int[]> getPopularTags(BookmarkReader reader, int sampleSize, int limit) { timeString = ""; List<int[]> tags = new ArrayList<int[]>(); Stopwatch timer = new Stopwatch(); timer.start(); int[] tagIDs = getPopularTagList(reader, limit); timer.stop();//ww w . ja v a 2 s .c o m long trainingTime = timer.elapsed(TimeUnit.MILLISECONDS); timer = new Stopwatch(); timer.start(); for (int j = 0; j < sampleSize; j++) { tags.add(tagIDs); } timer.stop(); long testTime = timer.elapsed(TimeUnit.MILLISECONDS); timeString += ("Full training time: " + trainingTime + "\n"); timeString += ("Full test time: " + testTime + "\n"); timeString += ("Average test time: " + testTime / sampleSize) + "\n"; timeString += ("Total time: " + (trainingTime + testTime) + "\n"); return tags; }
From source file:processing.MPurCalculator.java
public static List<Map<Integer, Double>> startLanguageModelCreation(BookmarkReader reader, int sampleSize, boolean sorting, boolean userBased, boolean resBased, int beta) { int size = reader.getBookmarks().size(); int trainSize = size - sampleSize; Stopwatch timer = new Stopwatch(); timer.start(); MPurCalculator calculator = new MPurCalculator(reader, trainSize, beta, userBased, resBased); timer.stop();/* w ww .java2 s . c o m*/ long trainingTime = timer.elapsed(TimeUnit.MILLISECONDS); List<Map<Integer, Double>> results = new ArrayList<Map<Integer, Double>>(); if (trainSize == size) { trainSize = 0; } timer.reset(); timer.start(); for (int i = trainSize; i < size; i++) { // the test-set Bookmark data = reader.getBookmarks().get(i); Map<Integer, Double> map = calculator.getRankedTagList(data.getUserID(), data.getResourceID(), sorting); results.add(map); } timer.stop(); long testTime = timer.elapsed(TimeUnit.MILLISECONDS); timeString = PerformanceMeasurement.addTimeMeasurement(timeString, true, trainingTime, testTime, sampleSize); return results; }
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(); try {// ww w . j a va 2s.co m log.info("Starting DropWizard bundle ({})", bundle); bundle.start(); } catch (Exception e) { throw Throwables.propagate(e); } stopwatch.stop(); } return stopwatch; }
From source file:org.apache.drill.exec.physical.impl.ImplCreator.java
/** * Create and return fragment RootExec for given FragmentRoot. RootExec has one or more RecordBatches as children * (which may contain child RecordBatches and so on). * * @param context/*ww w.j av a2 s .c om*/ * FragmentContext. * @param root * FragmentRoot. * @return RootExec of fragment. * @throws ExecutionSetupException */ public static RootExec getExec(FragmentContext context, FragmentRoot root) throws ExecutionSetupException { Preconditions.checkNotNull(root); Preconditions.checkNotNull(context); if (AssertionUtil.isAssertionsEnabled()) { root = IteratorValidatorInjector.rewritePlanWithIteratorValidator(context, root); } final ImplCreator creator = new ImplCreator(); Stopwatch watch = new Stopwatch(); watch.start(); try { final RootExec rootExec = creator.getRootExec(root, context); // skip over this for SimpleRootExec (testing) if (rootExec instanceof BaseRootExec) { ((BaseRootExec) rootExec).setOperators(creator.getOperators()); } logger.debug("Took {} ms to create RecordBatch tree", watch.elapsed(TimeUnit.MILLISECONDS)); if (rootExec == null) { throw new ExecutionSetupException( "The provided fragment did not have a root node that correctly created a RootExec value."); } return rootExec; } catch (Exception e) { context.fail(e); for (final CloseableRecordBatch crb : creator.getOperators()) { AutoCloseables.close(crb, logger); } } return null; }
From source file:processing.LanguageModelCalculator.java
public static List<Map<Integer, Double>> startLanguageModelCreation(BookmarkReader reader, int sampleSize, boolean sorting, boolean userBased, boolean resBased, int beta, boolean smoothing) { timeString = ""; int size = reader.getUserLines().size(); int trainSize = size - sampleSize; Stopwatch timer = new Stopwatch(); timer.start(); LanguageModelCalculator calculator = new LanguageModelCalculator(reader, trainSize, beta, userBased, resBased);/*from w w w .j av a2 s .co m*/ timer.stop(); long trainingTime = timer.elapsed(TimeUnit.MILLISECONDS); List<Map<Integer, Double>> results = new ArrayList<Map<Integer, Double>>(); if (trainSize == size) { trainSize = 0; } timer = new Stopwatch(); timer.start(); for (int i = trainSize; i < size; i++) { // the test-set UserData data = reader.getUserLines().get(i); Map<Integer, Double> map = calculator.getRankedTagList(data.getUserID(), data.getWikiID(), sorting, smoothing); results.add(map); } timer.stop(); long testTime = timer.elapsed(TimeUnit.MILLISECONDS); timeString += ("Full training time: " + trainingTime + "\n"); timeString += ("Full test time: " + testTime + "\n"); timeString += ("Average test time: " + testTime / (double) sampleSize) + "\n"; timeString += ("Total time: " + (trainingTime + testTime) + "\n"); return results; }
From source file:org.sonatype.sisu.bl.servlet.jetty.testsuite.JettyITSupport.java
protected static Stopwatch startJetty(final JettyBundle jettyBundle) { final Stopwatch stopwatch = Stopwatch.createUnstarted(); if (jettyBundle != null && !jettyBundle.isRunning()) { stopwatch.start(); try {//from ww w.j ava 2 s . c o m LOGGER.info("Starting Jetty ({})", jettyBundle); jettyBundle.start(); } catch (Exception e) { throw Throwables.propagate(e); } stopwatch.stop(); } return stopwatch; }
From source file:com.springer.omelet.driver.DriverUtility.java
/*** * Generic waitFor Function which waits for condition to be successful else * return null/*from w ww . ja v a2 s . c o m*/ * * @param expectedCondition * :ExpectedCondition<T> * @param driver * :WebDriver * @param timeout * in seconds * @return <T> or null */ public static <T> T waitFor(ExpectedCondition<T> expectedCondition, WebDriver driver, int timeOutInSeconds) { Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); try { T returnValue = new WebDriverWait(driver, timeOutInSeconds).pollingEvery(500, TimeUnit.MILLISECONDS) .until(expectedCondition); return returnValue; } catch (TimeoutException e) { LOGGER.error(e); return null; } finally { driver.manage().timeouts().implicitlyWait(Driver.getBrowserConf().getDriverTimeOut(), TimeUnit.SECONDS); stopwatch.stop(); LOGGER.debug("Time Taken for waitFor method for Expected Condition is:" + stopwatch.elapsedTime(TimeUnit.SECONDS)); } }
From source file:processing.LayersCalculator.java
public static void predictSample(String filename, int trainSize, int sampleSize, int beta) { //filename += "_res"; BookmarkReader reader = new BookmarkReader(trainSize, false); reader.readFile(filename);/* w ww. j av a 2 s. co m*/ List<int[]> predictionValues = new ArrayList<int[]>(); Stopwatch timer = new Stopwatch(); timer.start(); LayersCalculator calculator = new LayersCalculator(reader, trainSize, beta); timer.stop(); long trainingTime = timer.elapsed(TimeUnit.MILLISECONDS); timer = new Stopwatch(); timer.start(); for (int i = trainSize; i < trainSize + sampleSize; i++) { // the test-set UserData data = reader.getUserLines().get(i); Map<Integer, Double> map = calculator.getRankedTagList(data.getUserID(), data.getWikiID(), data.getCategories()); predictionValues.add(Ints.toArray(map.keySet())); } timer.stop(); long testTime = timer.elapsed(TimeUnit.MILLISECONDS); timeString += ("Full training time: " + trainingTime + "\n"); timeString += ("Full test time: " + testTime + "\n"); timeString += ("Average test time: " + testTime / (double) sampleSize) + "\n"; timeString += ("Total time: " + (trainingTime + testTime) + "\n"); String outputFile = filename + "_3layers"; Utilities.writeStringToFile("./data/metrics/" + outputFile + "_TIME.txt", timeString); reader.setUserLines(reader.getUserLines().subList(trainSize, reader.getUserLines().size())); PredictionFileWriter writer = new PredictionFileWriter(reader, predictionValues); writer.writeFile(outputFile); }
From source file:org.apache.drill.exec.store.schedule.BlockMapBuilder.java
/** * Builds a mapping of Drillbit endpoints to hostnames *///w w w. j av a 2 s . c o m private static ImmutableMap<String, DrillbitEndpoint> buildEndpointMap(Collection<DrillbitEndpoint> endpoints) { Stopwatch watch = new Stopwatch(); watch.start(); HashMap<String, DrillbitEndpoint> endpointMap = Maps.newHashMap(); for (DrillbitEndpoint d : endpoints) { String hostName = d.getAddress(); endpointMap.put(hostName, d); } watch.stop(); logger.debug("Took {} ms to build endpoint map", watch.elapsed(TimeUnit.MILLISECONDS)); return ImmutableMap.copyOf(endpointMap); }