List of usage examples for com.google.common.base Stopwatch stop
public Stopwatch stop()
From source file:es.usc.citius.composit.wsc08.data.knowledge.WSCXMLKnowledgeBase.java
private void initialize() { // Load all superclasses, subclasses and instances logger.debug("Initializing WSCXMLKnowledgeBase (root concept {})", taxonomy.getConcept().getID()); Stopwatch stopwatch = Stopwatch.createStarted(); populate(taxonomy.getConcept());//from ww w . ja va 2 s. c o m logger.debug("Knowledge base created in {}. Total concepts {}.", stopwatch.stop().toString(), conceptID.keySet().size()); }
From source file:org.hyperledger.perftest.SendTransactionThroughputMeasure.java
private List<Long> measureSingleThreaded() throws Exception { List<Long> results = new ArrayList<>(getRounds()); for (int i = 0; i < getRounds(); i++) { System.out.println("Measuring round " + i); List<Transaction> txsForOneRound = txs.get(i); System.gc();// w ww. j a v a 2s . c om System.gc(); System.gc(); System.gc(); System.gc(); Stopwatch watch = Stopwatch.createStarted(); for (Transaction tx : txsForOneRound) { api.sendTransaction(tx); } watch.stop(); results.add(watch.elapsed(TimeUnit.MILLISECONDS)); } return results; }
From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.loadsimulator.net.RestMetricsSender.java
/** * Push metrics to the REST endpoint. Connection is always open and closed on every call. * * @param payload the payload with metrics to be sent to metrics service * @return response message either acknowledgement or error, empty on exception *//*from ww w .ja v a 2 s . co m*/ @Override public String pushMetrics(String payload) { String responseString = ""; UrlService svc = null; Stopwatch timer = new Stopwatch().start(); try { LOG.info("server: {}", collectorServiceAddress); svc = getConnectedUrlService(); responseString = svc.send(payload); timer.stop(); LOG.info("http response time: " + timer.elapsedMillis() + " ms"); if (responseString.length() > 0) { LOG.debug("POST response from server: " + responseString); } } catch (MalformedURLException e) { LOG.error("", e); } catch (ProtocolException e) { LOG.error("", e); } catch (IOException e) { LOG.error("", e); } finally { if (svc != null) { svc.disconnect(); } } return responseString; }
From source file:com.pedra.storefront.filters.RequestLoggerFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { if (LOG.isDebugEnabled()) { final String requestDetails = buildRequestDetails(request); if (LOG.isDebugEnabled()) { LOG.debug(requestDetails + "Begin"); }//w w w .jav a2 s . c o m logCookies(request); final ResponseWrapper wrappedResponse = new ResponseWrapper(response); final Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); try { filterChain.doFilter(request, wrappedResponse); } finally { stopwatch.stop(); final int status = wrappedResponse.getStatus(); if (status != 0) { LOG.debug(requestDetails + stopwatch.toString() + " (" + status + ")"); } else { LOG.debug(requestDetails + stopwatch.toString()); } } return; } filterChain.doFilter(request, response); }
From source file:com.jiuxian.mossrose.quartz.QuartzJobWrapper.java
@Override public void execute(JobExecutionContext context) throws JobExecutionException { try {// w ww . jav a 2 s . co m final Stopwatch watch = Stopwatch.createStarted(); final JobHandler mJobHandler = JobHandlerFactory.getInstance() .getMJobHandler(ObjectContainer.getClazz(jobMeta.getId())); mJobHandler.handle(jobMeta, ignite, runOnMaster); watch.stop(); LOGGER.info("Job {} use time: {} ms.", jobMeta.getId(), watch.elapsed(TimeUnit.MILLISECONDS)); } catch (Exception e) { LOGGER.error("Error while executing job " + context.getJobDetail().getKey(), e); } }
From source file:org.graylog2.indexer.ranges.MongoIndexRangeService.java
@Override public IndexRange calculateRange(String index) { indices.waitForRecovery(index);//from ww w . j a v a 2 s.c o m final DateTime now = DateTime.now(DateTimeZone.UTC); final Stopwatch sw = Stopwatch.createStarted(); final TimestampStats stats = indices.timestampStatsOfIndex(index); final int duration = Ints.saturatedCast(sw.stop().elapsed(TimeUnit.MILLISECONDS)); LOG.info("Calculated range of [{}] in [{}ms].", index, duration); return MongoIndexRange.create(index, stats.min(), stats.max(), now, duration); }
From source file:com.davidbracewell.ml.sequence.hmm.MLFirstOrderHMMLearner.java
@Override protected void trainAllInstances(List<List<Instance>> instances) { log.info("Beginning training [{0} examples] ...", instances.size()); Stopwatch sw = Stopwatch.createStarted(); for (Iterator<List<Instance>> iterator = instances.iterator(); iterator.hasNext();) { trainOneSequence(iterator.next()); iterator.remove();//from w w w .j a va2s. c o m } sw.stop(); log.info("Finished training in {0}", sw); }
From source file:org.eclipse.osee.orcs.core.internal.types.impl.CreateOrcsTypesIndexCallable.java
@Override public OrcsTypesIndex call() throws Exception { Stopwatch stopwatch = new Stopwatch(); stopwatch.start();/* w ww .j a va 2s . c om*/ OrcsTypesIndex index = null; try { index = createIndex(); } finally { logger.trace("Created OrcsTypesIndex in [%s]", Lib.getElapseString(stopwatch.elapsedMillis())); stopwatch.stop(); } return index; }
From source file:com.vmm.storefront.filters.RequestLoggerFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { if (LOG.isDebugEnabled()) { final String requestDetails = buildRequestDetails(request); writeDebugLog(requestDetails, "Begin"); logCookies(request);/* w w w. j a v a2s . com*/ final ResponseWrapper wrappedResponse = new ResponseWrapper(response); final Stopwatch stopwatch = Stopwatch.createUnstarted(); stopwatch.start(); try { filterChain.doFilter(request, wrappedResponse); } finally { stopwatch.stop(); final int status = wrappedResponse.getStatus(); if (status != 0) { writeDebugLog(requestDetails, stopwatch.toString(), " (", String.valueOf(status), ")"); } else { writeDebugLog(requestDetails, stopwatch.toString()); } } return; } filterChain.doFilter(request, response); }
From source file:hu.vodafone.storefront.filters.RequestLoggerFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { if (LOG.isDebugEnabled()) { final String requestDetails = buildRequestDetails(request); if (LOG.isDebugEnabled()) { LOG.debug(requestDetails + "Begin"); }/*from w w w . ja va 2 s .c o m*/ logCookies(request); final ResponseWrapper wrappedResponse = new ResponseWrapper(response); final Stopwatch stopwatch = Stopwatch.createUnstarted(); stopwatch.start(); try { filterChain.doFilter(request, wrappedResponse); } finally { stopwatch.stop(); final int status = wrappedResponse.getStatus(); if (status != 0) { LOG.debug(requestDetails + stopwatch.toString() + " (" + status + ")"); } else { LOG.debug(requestDetails + stopwatch.toString()); } } return; } filterChain.doFilter(request, response); }