List of usage examples for org.springframework.util StopWatch getTotalTimeMillis
public long getTotalTimeMillis()
From source file:ch.silviowangler.dox.LoadIntegrationTest.java
@Test @Ignore("Needs rework since it produces unreliable results") public void testQuery() throws Exception { StopWatch stopWatch = new StopWatch(); Map<TranslatableKey, DescriptiveIndex> indices = new HashMap<>(); TranslatableKey company = new TranslatableKey("company"); indices.put(company, new DescriptiveIndex("3?")); stopWatch.start();/* w w w . j av a2 s .c om*/ Set<DocumentReference> invoices = documentService.findDocumentReferences(indices, "INVOICE"); stopWatch.stop(); final long totalTimeMillis = stopWatch.getTotalTimeMillis(); assertTrue("This test may take only " + TOTAL_AMOUNT_OF_TIME_IN_MILLIS + " ms but took this time " + totalTimeMillis + " ms", totalTimeMillis <= TOTAL_AMOUNT_OF_TIME_IN_MILLIS); for (DocumentReference documentReference : invoices) { String value = documentReference.getIndices().get(company).toString(); assertTrue("Value is wrong: " + value, value.matches("(3|3\\d)")); } assertThat(invoices.size(), is(11)); }
From source file:org.bpmscript.correlation.CorrelationSupportTest.java
public void testHashPerformance() throws Exception { CorrelationSupport correlationSupport = new CorrelationSupport(); StopWatch md5Watch = new StopWatch(); Object[] values = new Object[3]; values[0] = 100000;//w ww . j ava 2 s. c o m values[1] = "test "; values[2] = "randomblahblah"; byte[] bytes = correlationSupport.getBytes(values); md5Watch.start(); for (int i = 0; i < 100000; i++) { getHashMD5(bytes); } md5Watch.stop(); System.out.println(md5Watch.getTotalTimeMillis()); StopWatch hashCodeWatch = new StopWatch(); hashCodeWatch.start(); for (int i = 0; i < 100000; i++) { getHashHashCode(bytes); } hashCodeWatch.stop(); System.out.println(hashCodeWatch.getTotalTimeMillis()); }
From source file:com.alienlab.SwaggerConfiguration.java
@Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start();/*from www . ja va 2 s. c o m*/ 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:org.sharetask.utility.log.PerformanceInterceptor.java
@SuppressWarnings("PMD.AvoidCatchingThrowable") @Override/*from w w w . j ava 2 s .c om*/ protected Object invokeUnderTrace(final MethodInvocation invocation, final Log logger) throws Throwable { final String name = invocation.getMethod().getDeclaringClass().getName() + "." + invocation.getMethod().getName(); final StopWatch stopWatch = new StopWatch(name); Object returnValue = null; try { stopWatch.start(name); returnValue = invocation.proceed(); return returnValue; } catch (final Throwable ex) { if (stopWatch.isRunning()) { stopWatch.stop(); } throw ex; } finally { if (stopWatch.isRunning()) { stopWatch.stop(); } writeToLog(logger, replacePlaceholders(exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis())); } }
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. j av a 2 s . c o 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.todo.backend.config.SwaggerConfiguration.java
@Bean public Docket swaggerSpringfoxDocket() { log.debug("Initializing swagger..."); final StopWatch watch = new StopWatch(); watch.start();//from w w w . j av a2s. c om final Docket docket = new Docket(DocumentationType.SWAGGER_2).forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class).ignoredParameterTypes(Pageable.class) .ignoredParameterTypes(java.sql.Date.class) .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalTime.class, Date.class).select() .paths(PathSelectors.regex("/api/.*")).build(); watch.stop(); log.debug("Swagger started in {} ms", watch.getTotalTimeMillis()); return docket; }
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 .ja va2 s . c o m } 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.dd4t.core.filters.impl.RichTextResolverFilter.java
/** * Recursivly resolves all components links. * /* w w w .j a v a 2s . c o m*/ * @param item * the to resolve the links * @param context * the requestContext */ @Override public void doFilter(Item item, RequestContext context) throws FilterException { StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); } if (item instanceof GenericPage) { resolvePage((GenericPage) item); } else if (item instanceof GenericComponent) { resolveComponent((GenericComponent) item); } else { if (logger.isDebugEnabled()) { logger.debug( "RichTextResolverFilter. Item is not a GenericPage or GenericComponent so no component to resolve"); } } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("RichTextResolverFilter finished in " + stopWatch.getTotalTimeMillis() + " ms"); } }
From source file:org.dd4t.core.factories.impl.SimplePageFactory.java
private Page findSimplePageByUrl(String url, int publicationId, RequestContext context) throws ItemNotFoundException, NotAuthorizedException, NotAuthenticatedException { if (context == null && securityFilterPresent()) { throw new RuntimeException("use of findPageByUrl is not allowed when a SecurityFilter is set"); }//from w w w.j a v a 2 s .co m StopWatch stopWatch = null; if (logger.isDebugEnabled()) { logger.debug("Enter findSimplePageByUrl url: " + url + " and publicationId: " + publicationId); stopWatch = new StopWatch("findSimplePageByUrl"); stopWatch.start(); } PageMeta pageMeta = null; Page page = null; try { pageMeta = brokerPageProvider.getPageMetaByURL(url, publicationId); if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Got pageMeta in " + stopWatch.getTotalTimeMillis() + " ms"); stopWatch.start(); } page = (Page) getPageFromMeta(pageMeta); if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Got Page in " + stopWatch.getTotalTimeMillis() + " ms"); stopWatch.start(); } try { // run all filters regardless if they are allowed to be cached // or not doFilters(page, context, BaseFilter.RunPhase.Both); } catch (FilterException e) { logger.error("Error in filter. ", e); throw new RuntimeException(e); } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Ran filters in " + stopWatch.getTotalTimeMillis() + " ms"); stopWatch.start(); } } catch (StorageException e) { logger.error("Storage exception when searching for page: " + url, e); throw new RuntimeException(e); } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("Exit findSimplePageByUrl (" + stopWatch.getTotalTimeMillis() + " ms)"); } return page; }
From source file:org.impalaframework.extension.mvc.flash.FlashStateEnabledAnnotationHandlerAdapter.java
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { RequestModelHelper.maybeDebugRequest(logger, request); StopWatch watch = null; final boolean debugEnabled; if (logger.isDebugEnabled()) { debugEnabled = true;//from w w w .ja v a2 s . co m } else { debugEnabled = false; } try { if (debugEnabled) { watch = new StopWatch(); watch.start(); logger.debug(MemoryUtils.getMemoryInfo().toString()); } beforeHandle(request); ModelAndView modelAndView = super.handle(request, response, handler); if (modelAndView != null) { afterHandle(request, modelAndView); return modelAndView; } } finally { if (debugEnabled) { watch.stop(); logger.debug("Request executed in " + watch.getTotalTimeMillis() + " milliseconds"); } } return null; }