List of usage examples for org.springframework.util StopWatch stop
public void stop() throws IllegalStateException
From source file:com.alienlab.SwaggerConfiguration.java
@Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start();/*w ww .j a va 2s . com*/ Contact contact = new Contact(contactName, contactUrl, contactEmail); ApiInfo apiInfo = new ApiInfo(title, description, version, termsOfServiceUrl, contact, license, licenseUrl); Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class).select().paths(regex(DEFAULT_INCLUDE_PATTERN)) .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
From source file:com.github.totyumengr.minicubes.core.MiniCubeTest.java
@Test public void test_5_1_Distinct_20140606() throws Throwable { StopWatch stopWatch = new StopWatch(); stopWatch.start();/*from w ww . j a v a 2 s .c o m*/ Map<String, List<Integer>> filter = new HashMap<String, List<Integer>>(1); Map<Integer, RoaringBitmap> distinct = miniCube.distinct("postId", true, "tradeId", filter); stopWatch.stop(); Assert.assertEquals(210, distinct.size()); Assert.assertEquals(3089, distinct.get(1601).getCardinality()); Assert.assertEquals(1825, distinct.get(1702).getCardinality()); Assert.assertEquals(2058, distinct.get(-2).getCardinality()); LOGGER.info(stopWatch.getTotalTimeSeconds() + " used for distinct result {}", distinct.toString()); }
From source file:org.ameba.aop.IntegrationLayerAspect.java
/** * Around intercepted methods do some logging and exception translation. <p> <ul> <li> Set log level of {@link * LoggingCategories#INTEGRATION_LAYER_ACCESS} to INFO to enable method tracing. <li>Set log level of {@link * LoggingCategories#INTEGRATION_LAYER_EXCEPTION} to ERROR to enable exception logging. </ul> </p> * * @param pjp The joinpoint//from w w w . java2s.co m * @return Method return value * @throws Throwable in case of errors */ @Around("org.ameba.aop.Pointcuts.integrationPointcut()") public Object measure(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = null; if (P_LOGGER.isInfoEnabled()) { sw = new StopWatch(); sw.start(); P_LOGGER.info("[I]>> {}#{}", pjp.getTarget().getClass().getSimpleName(), pjp.getSignature().getName()); } try { return pjp.proceed(); } catch (Exception ex) { throw translateException(ex); } finally { if (P_LOGGER.isInfoEnabled() && sw != null) { sw.stop(); P_LOGGER.info("[I]<< {}#{} took {} [ms]", pjp.getTarget().getClass().getSimpleName(), pjp.getSignature().getName(), sw.getTotalTimeMillis()); } } }
From source file:com.ethlo.kfka.KfkaApplicationTests.java
@Test public void testPerformance1() throws InterruptedException { kfkaManager.clearAll();// www . j a v a2 s . c o m final int count = 10_000; final StopWatch sw = new StopWatch(); sw.start("Insert1"); for (int i = 1; i <= count; i++) { kfkaManager.add(new CustomKfkaMessageBuilder().userId(321).payload("otherMessage" + i) .timestamp(System.currentTimeMillis()).topic("bar").type("mytype").build()); } sw.stop(); sw.start("Insert2"); for (int i = 1; i <= count; i++) { kfkaManager.add(new CustomKfkaMessageBuilder().userId(123).payload("myMessage" + 1) .timestamp(System.currentTimeMillis()).topic("bar").type("mytype").build()); } sw.stop(); sw.start("Query"); final CollectingListener collListener = new CollectingListener(); kfkaManager.addListener(collListener, new KfkaPredicate().topic("bar").relativeOffset(-(count + 10)).addPropertyMatch("userId", 123)); sw.stop(); assertThat(collListener.getReceived()).hasSize(count); assertThat(collListener.getReceived().get(0).getId()).isEqualTo(count + 1); assertThat(collListener.getReceived().get(count - 1).getId()).isEqualTo(count + count); logger.info("Timings: {}", sw); }
From source file:org.dd4t.core.factories.impl.GenericComponentFactory.java
public DynamicComponent getDCPFromSource(com.tridion.dcp.ComponentPresentation dcp) { StopWatch stopWatch = null; DynamicComponentImpl dynComp = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch("getComponentFromSource"); stopWatch.start();//from w w w. j a v a 2 s . c om } try { if (logger.isDebugEnabled()) { stopWatch.stop(); stopWatch.start(); } dynComp = (DynamicComponentImpl) this.getSerializer().deserialize(dcp.getContent(), DynamicComponentImpl.class); dynComp.setNativeDCP(dcp); } catch (Exception e) { logger.error("error when deserializing component", e); throw new RuntimeException(e); } finally { if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Deserialization of component took: " + stopWatch.getLastTaskTimeMillis() + " ms"); } } return dynComp; }
From source file:com.chf.sample.spring.config.SwaggerConfig.java
@Bean public Docket swaggerSpringfoxDocket() { StopWatch watch = new StopWatch(); watch.start();/*from w ww . ja va 2 s. c o m*/ Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select() .paths(regex(DEFAULT_INCLUDE_PATTERN)).build(); watch.stop(); return docket; }
From source file:com.persistent.cloudninja.scheduler.TenantWebBandWidthUsageProcessor.java
@Override public boolean execute() { StopWatch watch = new StopWatch(); LOGGER.info("Start of TenantWebBandWidthUsageProcessor:execute"); boolean returnFlag = true; TenantWebBandWidthUsageQueue queue = (TenantWebBandWidthUsageQueue) getWorkQueue(); try {//from w ww . j av a 2 s. c om watch.start(); List<WebLogMeteringBatch> list = queue.dequeue(); LOGGER.debug("Queue List Size :" + list.size()); for (int i = 0; i < list.size(); i++) { tenantWebBandWidthUsageProcessUtility.getTenantWebBandWidthUsage(list.get(i)); } watch.stop(); taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "ProcessMeteringWebAppBandwidth", "Processed a batch of " + list.size() + " Tomcat Logs"); } catch (StorageException e) { returnFlag = false; LOGGER.error(e.getMessage(), e); } catch (ParseException e) { returnFlag = false; LOGGER.error(e.getMessage(), e); } LOGGER.debug("ReturnFlag :" + returnFlag); LOGGER.info("End of TenantWebBandWidthUsageProcessor:execute"); return returnFlag; }
From source file:org.dd4t.core.filters.impl.DefaultLinkResolverFilter.java
protected void resolveComponentLinkField(ComponentLinkField componentLinkField) { StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start();/*from w w w . j a v a2 s .c om*/ } List<Object> compList = componentLinkField.getValues(); for (Object component : compList) { resolveComponent((GenericComponent) component); } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Resolved componentLinkField '" + componentLinkField.getName() + "' in " + stopWatch.getTotalTimeMillis() + " ms."); } }
From source file:org.sventon.cache.logmessagecache.LogMessageCacheUpdater.java
/** * Updates the log entry cache with given revision information. * * @param revisionUpdate The updated revisions. *///w ww . jav a 2 s .c o m public void update(final RevisionUpdate revisionUpdate) { final RepositoryName repositoryName = revisionUpdate.getRepositoryName(); final List<LogEntry> revisions = revisionUpdate.getRevisions(); LOGGER.info( "Listener got [" + revisions.size() + "] updated revision(s) for repository: " + repositoryName); final StopWatch stopWatch = new StopWatch(); stopWatch.start(); try { final LogMessageCache logMessageCache = logMessageCacheManager.getCache(repositoryName); if (revisionUpdate.isClearCacheBeforeUpdate()) { LOGGER.info("Clearing cache before population"); logMessageCache.clear(); } updateInternal(logMessageCache, revisions); } catch (final Exception ex) { LOGGER.warn("Could not update cache instance [" + repositoryName + "]", ex); } stopWatch.stop(); LOGGER.info("Update completed in [" + stopWatch.getTotalTimeSeconds() + "] seconds"); }
From source file:fr.acxio.tools.agia.alfresco.configuration.SimpleNodeFactoryTest.java
@Test public void testGetNodes() throws Exception { FolderDefinition aDefaultNodeDefinition = NodeFactoryUtils.createFolderDefinition("test", null, null, null); // FieldSet aData = new DefaultFieldSet(new String[]{"A", "B", "C"}, new String[]{"A", "B", "C"}); StopWatch aStopWatch = new StopWatch("testGetNodes"); aStopWatch.start("Create a node list"); SimpleNodeFactory aNodeFactory = new SimpleNodeFactory(); aNodeFactory.setNamespaceContext(namespaceContext); aNodeFactory.setNodeDefinition(aDefaultNodeDefinition); NodeList aNodeList = aNodeFactory.getNodes(evaluationContext); aStopWatch.stop(); assertNotNull(aNodeList);//from w w w . j av a2 s. c om assertEquals(1, aNodeList.size()); assertTrue(aNodeList.get(0) instanceof Folder); Folder aFolder = (Folder) aNodeList.get(0); assertEquals("test", aFolder.getName()); assertNotNull(aFolder.getAspects()); assertEquals(0, aFolder.getAspects().size()); assertNotNull(aFolder.getAssociations()); assertEquals(0, aFolder.getAssociations().size()); assertNotNull(aFolder.getFolders()); assertEquals(0, aFolder.getFolders().size()); assertNotNull(aFolder.getDocuments()); assertEquals(0, aFolder.getDocuments().size()); assertNull(aFolder.getParent()); assertEquals("/cm:test", aFolder.getPath()); assertNotNull(aFolder.getType()); assertEquals("{http://www.alfresco.org/model/content/1.0}folder", aFolder.getType().toString()); System.out.println(aStopWatch.prettyPrint()); }