List of usage examples for com.google.common.base Stopwatch stop
public Stopwatch stop()
From source file:uk.ac.open.kmi.iserve.discovery.disco.impl.SparqlIndexedLogicConceptMatcher.java
@Inject protected SparqlIndexedLogicConceptMatcher(RegistryManager registryManager, @iServeProperty(ConfigurationProperty.SERVICES_SPARQL_QUERY) String sparqlEndpoint, CacheFactory cacheFactory) throws SalException, URISyntaxException { super(EnumMatchTypes.of(LogicConceptMatchType.class)); this.sparqlMatcher = new SparqlLogicConceptMatcher(sparqlEndpoint); this.manager = registryManager; this.manager.registerAsObserver(this); if (indexedMatches == null) { try {/*w ww. j a va 2 s . co m*/ this.indexedMatches = cacheFactory.createPersistentCache("concept-matcher-index"); } catch (CacheException e) { this.indexedMatches = cacheFactory.createInMemoryCache("concept-matcher-index"); } } if (indexedMatches.isEmpty()) { log.info("Populating Matcher Index...");// if index is empty Stopwatch w = new Stopwatch().start(); populate(); log.info("Population done in {}. Number of entries {}", w.stop().toString(), indexedMatches.size()); } }
From source file:org.graylog2.shared.initializers.PeriodicalsService.java
@Override protected void shutDown() throws Exception { for (Periodical periodical : periodicals.getAllStoppedOnGracefulShutdown()) { LOG.info("Shutting down periodical [{}].", periodical.getClass().getCanonicalName()); Stopwatch s = Stopwatch.createStarted(); // Cancel future executions. Map<Periodical, ScheduledFuture> futures = periodicals.getFutures(); if (futures.containsKey(periodical)) { futures.get(periodical).cancel(false); s.stop(); LOG.info("Shutdown of periodical [{}] complete, took <{}ms>.", periodical.getClass().getCanonicalName(), s.elapsed(TimeUnit.MILLISECONDS)); } else {// w w w .j av a 2 s . c om LOG.error("Could not find periodical [{}] in futures list. Not stopping execution.", periodical.getClass().getCanonicalName()); } } }
From source file:org.jnbis.imageio.WSQImageReader.java
private void processInput(final int imageIndex) { try {//from w ww . java 2 s . co m if (imageIndex != 0) { throw new IndexOutOfBoundsException("imageIndex " + imageIndex); } /* Already processed */ if (image != null) { return; } final Object input = getInput(); if (input == null) { this.image = null; return; } if (!(input instanceof ImageInputStream)) { throw new IllegalArgumentException("bad input: " + input.getClass().getCanonicalName()); } final Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); log.debug("Input:{}", getInput()); final BitmapWithMetadata bitmap = WSQDecoder.decode((ImageInputStream) getInput()); stopwatch.stop(); //log.debug("Decode took: {}",stopwatch.elapsed(TimeUnit.MILLISECONDS)); metadata = new WSQMetadata(); for (final Map.Entry<String, String> entry : bitmap.getMetadata().entrySet()) { //System.out.println(entry.getKey() + ": " + entry.getValue()); metadata.setProperty(entry.getKey(), entry.getValue()); } for (final String s : bitmap.getComments()) { //System.out.println("//"+s); metadata.addComment(s); } image = new BufferedImage(bitmap.getWidth(), bitmap.getHeight(), BufferedImage.TYPE_BYTE_GRAY); final byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); System.arraycopy(bitmap.getPixels(), 0, imageData, 0, bitmap.getLength()); } catch (final IOException ioe) { ioe.printStackTrace(); this.image = null; } }
From source file:jobs.ComputeStratifiedFrequencies.java
@Override public void doJob() throws Exception { Logger.info("Frequency computation started..."); Stopwatch stopwatch = Stopwatch.createUnstarted(); stopwatch.start();/*from w ww . ja v a 2s . c o 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:gov.nih.nci.firebird.selenium2.scalability.tests.TimedAction.java
public T time() { Stopwatch stopwatch = new Stopwatch(); stopwatch.start();/* w w w . java 2 s . c o m*/ T result; try { result = perform(); } catch (Exception e) { throw new RuntimeException("Unexpected Exception in execution of " + actionName, e); } stopwatch.stop(); long elapsedMillis = stopwatch.elapsed(TimeUnit.MILLISECONDS); System.out.println(actionName + " \t" + elapsedMillis); String timeoutMessage = "Exeuction time of " + elapsedMillis + " milliseconds exceeded timeout of " + timeoutSeconds + " for " + actionName; assertTrue(timeoutMessage, elapsedMillis <= timeoutSeconds * DateUtils.MILLIS_PER_SECOND); return result; }
From source file:com.google.api.ads.adwords.jaxws.extensions.kratu.data.KratuProcessor.java
public void processKratus(Date dateStart, Date dateEnd) throws InterruptedException { System.out.println("Processing Kratus for" + mccAccountId); // We use a Latch so the main thread knows when all the worker threads are complete. final CountDownLatch latch = new CountDownLatch(1); Stopwatch stopwatch = Stopwatch.createStarted(); RunnableKratu runnableKratu = createRunnableKratu(storageHelper, dateStart, dateEnd); ExecutorService executorService = Executors.newFixedThreadPool(1); runnableKratu.setLatch(latch);/* w w w . j ava 2 s. c o m*/ executorService.execute(runnableKratu); latch.await(); stopwatch.stop(); }
From source file:ch.ge.ve.protopoc.service.simulation.ElectionAdministrationSimulator.java
public List<Long> getTally() throws InvalidDecryptionProofException { TallyData tallyData = bulletinBoardService.getTallyData(); List<DecryptionProof> decryptionProofs = tallyData.getDecryptionProofs(); List<BigInteger> publicKeyShares = tallyData.getPublicKeyShares(); List<Encryption> finalShuffle = tallyData.getFinalShuffle(); List<List<BigInteger>> partialDecryptions = tallyData.getPartialDecryptions(); Stopwatch decryptionProofCheckWatch = Stopwatch.createStarted(); if (!tallyingAuthoritiesAlgorithm.checkDecryptionProofs(decryptionProofs, publicKeyShares, finalShuffle, partialDecryptions)) {// w w w. j av a2 s .c o m throw new InvalidDecryptionProofException("An invalid decryption proof was found"); } decryptionProofCheckWatch.stop(); perfLog.info(String.format("Administration : checked decryption proofs in %dms", decryptionProofCheckWatch.elapsed(TimeUnit.MILLISECONDS))); List<BigInteger> decryptions = tallyingAuthoritiesAlgorithm.getDecryptions(finalShuffle, partialDecryptions); List<List<Boolean>> votes = tallyingAuthoritiesAlgorithm.getVotes(decryptions, totalCandidateCount); // Additional verifications on the votes validity may be performed here. return IntStream.range(0, totalCandidateCount) .mapToLong(i -> votes.stream().filter(vote -> vote.get(i)).count()).boxed() .collect(Collectors.toList()); }
From source file:de.schildbach.wallet.data.AddressBookProvider.java
@Override public boolean onCreate() { final Stopwatch watch = Stopwatch.createStarted(); final Context context = getContext(); Logging.init(context.getFilesDir()); helper = new Helper(context); watch.stop(); log.info("{}.onCreate() took {}", getClass().getSimpleName(), watch); return true;//from ww w . ja v a 2 s . c o m }
From source file:com.webbfontaine.valuewebb.irms.core.RuleCallable.java
@Override public T call() throws Exception { Stopwatch stopwatch = Stopwatch.createStarted(); RuleContext ruleContext = ruleContextBuilder.createRuleContext(); TTSourceBean ttSourceBean = sourceBeanBuilder.createSourceBean(); T result = applyRule(criterion, ruleContext, ttSourceBean); stopwatch.stop(); LOGGER.debug("Rule: {} execution time for TT with id: {}, pds size: {} is: {}", new Object[] { criterion.getCode(), ttSourceBean.getTtId(), ttSourceBean.getTtNumberOfItems(), stopwatch }); return result; }
From source file:org.apache.drill.exec.store.AffinityCalculator.java
/** * Builds a mapping of drillbit endpoints to hostnames *//*from ww w .ja va 2s . co m*/ private void buildEndpointMap() { Stopwatch watch = new Stopwatch(); watch.start(); endPointMap = new HashMap<String, DrillbitEndpoint>(); 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)); }