List of usage examples for com.google.common.base Stopwatch elapsed
@CheckReturnValue public long elapsed(TimeUnit desiredUnit)
From source file:org.apache.drill.exec.store.parquet.columnreaders.BatchReader.java
protected void readAllFixedFields(long recordsToRead) throws Exception { Stopwatch timer = Stopwatch.createStarted(); if (readState.useAsyncColReader()) { readAllFixedFieldsParallel(recordsToRead); } else {//w w w. jav a 2 s .c o m readAllFixedFieldsSerial(recordsToRead); } readState.parquetReaderStats().timeFixedColumnRead.addAndGet(timer.elapsed(TimeUnit.NANOSECONDS)); }
From source file:com.fireball1725.firelib.FireMod.java
@Mod.EventHandler public final void init(FMLInitializationEvent event) { final Stopwatch stopwatch = Stopwatch.createStarted(); this.getLogger().info("Initialization (Started)"); proxy().initStart(event);// w w w . j a va2s . c o m proxy().registerCapabilities(); proxy().registerEventHandlers(); proxy().initEnd(event); this.getLogger().info("Initialization (Ended after " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms)"); }
From source file:org.glowroot.agent.embedded.init.EmbeddedAgentModule.java
@OnlyUsedByTests public UiModule getUiModule() throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(SECONDS) < 60) { if (uiModule != null) { return uiModule; }/*from w w w . j av a 2 s. c o m*/ MILLISECONDS.sleep(10); } throw new IllegalStateException("UI Module failed to start"); }
From source file:org.factcast.store.pgsql.internal.catchup.PgCatchUpFetchPage.java
public LinkedList<Fact> fetchIdFacts(@NonNull AtomicLong serial) { Stopwatch sw = Stopwatch.createStarted(); final LinkedList<Fact> list = new LinkedList<>(jdbc.query(PgConstants.SELECT_ID_FROM_CATCHUP, createSetter(serial, pageSize), new PgIdFactExtractor(serial))); sw.stop();//from ww w . j a v a 2 s . c o m log.debug("{} fetched next page of Ids for cid={}, limit={}, ser>{} in {}ms", req, clientId, pageSize, serial.get(), sw.elapsed(TimeUnit.MILLISECONDS)); return list; }
From source file:jobs.ComputeStratifiedFrequencies.java
@Override public void doJob() throws Exception { Logger.info("Frequency computation started..."); Stopwatch stopwatch = Stopwatch.createUnstarted(); stopwatch.start();//from www . ja va 2 s .co m int now = Integer.parseInt((String) play.Play.configuration.get("analysis.year")); int y1 = now - 1; Logger.info("Previous year: " + y1); Logger.info("Reading index..."); Directory directory = FSDirectory.open(VirtualFile.fromRelativePath("/indexes/index-" + y1).getRealFile()); DirectoryReader ireader = DirectoryReader.open(directory); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_47); this.isearcher = new IndexSearcher(ireader); this.parser = new QueryParser(Version.LUCENE_47, "contents", analyzer); //Retrieve all the phrases in the database, and compute Logger.info("Retrieving phrases..."); List<Phrase> phrases = Phrase.findAll(); int total = phrases.size(); int counter = 0; Map<Long, Double> frequencies = new HashMap<Long, Double>(); for (Phrase phrase : phrases) { Stopwatch time = Stopwatch.createUnstarted(); time.start(); counter++; Logger.info("i: " + counter + "/" + total + " (" + phrase.value + ")"); int frequency = query(phrase.value); time.stop(); Logger.info("- Query time: " + time.elapsed(TimeUnit.MILLISECONDS)); //Try to save it to debug frequencies.put(phrase.id, (double) frequency); } // Phrase.em().flush(); // Phrase.em().clear(); counter = 0; for (Long id : frequencies.keySet()) { Phrase phrase = Phrase.findById(id); phrase.frequency1y = frequencies.get(id); phrase.save(); counter++; Logger.info("Counter: " + counter); if (counter % 1000 == 0) { Phrase.em().flush(); Phrase.em().clear(); } } ireader.close(); directory.close(); Logger.info("Job done."); stopwatch.stop(); Utils.emailAdmin("Stratified index built", "Job finished in " + stopwatch.elapsed(TimeUnit.MINUTES) + " minutes."); }
From source file:org.factcast.store.pgsql.internal.catchup.PgCatchUpFetchPage.java
public LinkedList<Fact> fetchFacts(@NonNull AtomicLong serial) { Stopwatch sw = Stopwatch.createStarted(); final LinkedList<Fact> list = new LinkedList<>(jdbc.query(PgConstants.SELECT_FACT_FROM_CATCHUP, createSetter(serial, pageSize), new PgFactExtractor(serial))); sw.stop();/*from ww w .j a v a 2 s. c o m*/ log.debug("{} fetched next page of Facts for cid={}, limit={}, ser>{} in {}ms", req, clientId, pageSize, serial.get(), sw.elapsed(TimeUnit.MILLISECONDS)); return list; }
From source file:com.google.gerrit.server.schema.SchemaVersion.java
private void migrateData(List<SchemaVersion> pending, UpdateUI ui, CurrentSchemaVersion curr, ReviewDb db) throws OrmException, SQLException { for (SchemaVersion v : pending) { Stopwatch sw = Stopwatch.createStarted(); ui.message(String.format("Migrating data to schema %d ...", v.getVersionNbr())); v.migrateData(db, ui);// ww w . j av a2 s .c o m v.finish(curr, db); ui.message(String.format("\t> Done (%.3f s)", sw.elapsed(TimeUnit.MILLISECONDS) / 1000d)); } }
From source file:be.nbb.cli.util.BasicCliLauncher.java
public void launch(@Nonnull String[] args) { ArgsParser<T> parser = parserSupplier.get(); T params = null;/*from w w w . ja va 2s. c om*/ 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); } }
From source file:org.obm.push.mail.greenmail.GreenMailExternalProcess.java
private List<String> readProcessOutputLinesUntilStartedTag() throws IOException, InterruptedException { List<String> outputLines = Lists.newArrayList(); Stopwatch stopwatch = Stopwatch.createStarted(); do {/* w w w .j a v a 2 s.co m*/ outputLines.addAll(CharStreams.readLines(readProcessOutput())); if (outputLines.contains(STARTED_TAG)) { return outputLines; } Thread.sleep(5); } while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < MAX_PROCESS_STARTTIME); throw new ExternalProcessException( "Process started tag not received in accepted delay of : " + MAX_PROCESS_STARTTIME + " ms"); }
From source file:org.factcast.store.pgsql.internal.catchup.PgCatchUpPrepare.java
@SuppressWarnings("ConstantConditions") public long prepareCatchup(AtomicLong serial) { PgQueryBuilder b = new PgQueryBuilder(req); long clientId = jdbc.queryForObject(PgConstants.NEXT_FROM_CATCHUP_SEQ, Long.class); String catchupSQL = b.catchupSQL(clientId); // noinspection ConstantConditions return jdbc.execute(catchupSQL, (PreparedStatementCallback<Long>) ps -> { log.debug("{} preparing paging for matches after {}", req, serial.get()); try {/* w ww . ja v a 2 s .com*/ Stopwatch sw = Stopwatch.createStarted(); b.createStatementSetter(serial).setValues(ps); int numberOfFactsToCatchup = ps.executeUpdate(); sw.stop(); if (numberOfFactsToCatchup > 0) { log.debug("{} prepared {} facts for cid={} in {}ms", req, numberOfFactsToCatchup, clientId, sw.elapsed(TimeUnit.MILLISECONDS)); return clientId; } else { log.debug("{} nothing to catch up", req); return 0L; } } catch (SQLException ex) { log.error("While trying to prepare catchup", ex); throw ex; } }); }