Search in sources :

Example 26 with StopWatch

use of org.springframework.util.StopWatch in project nikita-noark5-core by HiOA-ABI.

the class SwaggerConfig method swaggerDocket.

@Bean
public Docket swaggerDocket() {
    // @formatter:off
    logger.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(webappProperties.getSwagger().getContactName(), webappProperties.getSwagger().getContactUrl(), webappProperties.getSwagger().getContactEmail());
    ApiInfo apiInfo = new ApiInfo(webappProperties.getSwagger().getTitle(), webappProperties.getSwagger().getDescription(), webappProperties.getSwagger().getVersion(), webappProperties.getSwagger().getTermsOfServiceUrl(), contact, webappProperties.getSwagger().getLicense(), webappProperties.getSwagger().getLicenseUrl());
    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).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.LocalDateTime.class, Date.class).select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build().pathMapping(Constants.HATEOAS_API_PATH).genericModelSubstitutes(ResponseEntity.class);
    watch.stop();
    logger.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
// @formatter:on
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiInfo(springfox.documentation.service.ApiInfo) Docket(springfox.documentation.spring.web.plugins.Docket) Date(java.util.Date) StopWatch(org.springframework.util.StopWatch) Contact(springfox.documentation.service.Contact) Bean(org.springframework.context.annotation.Bean)

Example 27 with StopWatch

use of org.springframework.util.StopWatch in project cu-kfs by CU-CommunityApps.

the class AccountReversionCurrentYearAccountStep method getCustomBatchExecutor.

/**
 * @see org.kuali.kfs.sys.batch.AbstractWrappedBatchStep#getCustomBatchExecutor()
 */
@Override
protected CustomBatchExecutor getCustomBatchExecutor() {
    return new CustomBatchExecutor() {

        /**
         * Runs the account reversion process, retrieving parameter, creating the origin entry group for output entries, and
         * generating the reports on the process.
         * @return true if the job completed successfully, false if otherwise
         * @see org.kuali.kfs.kns.bo.Step#execute(String, java.util.Date)
         */
        public boolean execute() {
            StopWatch stopWatch = new StopWatch();
            stopWatch.start("AccountReversionCurrentYearAccountStep");
            Map jobParameters = accountReversionProcessService.getJobParameters();
            Map<String, Integer> accountReversionCounts = new HashMap<String, Integer>();
            getYearEndService().logAllMissingSubFundGroups((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
            getAccountReversionProcessService().reversionCurrentYearAccountProcess(jobParameters, accountReversionCounts);
            stopWatch.stop();
            LOG.info("AccountReversionCurrentYearAccountStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
            return true;
        }
    };
}
Also used : CustomBatchExecutor(org.kuali.kfs.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) StopWatch(org.springframework.util.StopWatch)

Example 28 with StopWatch

use of org.springframework.util.StopWatch in project cu-kfs by CU-CommunityApps.

the class AccountReversionPriorYearAccountStep method getCustomBatchExecutor.

/**
 * @see org.kuali.kfs.sys.batch.AbstractWrappedBatchStep#getCustomBatchExecutor()
 */
@Override
protected CustomBatchExecutor getCustomBatchExecutor() {
    return new CustomBatchExecutor() {

        /**
         * Runs the account reversion process, retrieving parameter, creating the origin entry group for output entries, and
         * generating the reports on the process.
         * @return true if the job completed successfully, false if otherwise
         * @see org.kuali.kfs.kns.bo.Step#execute(java.lang.String)
         */
        public boolean execute() {
            StopWatch stopWatch = new StopWatch();
            stopWatch.start("AccountReversionPriorYearAccountStep");
            Map jobParameters = accountReversionProcessService.getJobParameters();
            Map<String, Integer> accountReversionCounts = new HashMap<String, Integer>();
            getYearEndService().logAllMissingPriorYearAccounts((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
            getYearEndService().logAllMissingSubFundGroups((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
            getAccountReversionProcessService().reversionPriorYearAccountProcess(jobParameters, accountReversionCounts);
            stopWatch.stop();
            LOG.info("Account ReversionPriorYearAccountStep took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
            return true;
        }
    };
}
Also used : CustomBatchExecutor(org.kuali.kfs.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) StopWatch(org.springframework.util.StopWatch)

Example 29 with StopWatch

use of org.springframework.util.StopWatch in project spring-integration by spring-projects.

the class MessageHistoryIntegrationTests method testMessageHistoryWithHistoryPerformance.

@Test
@Ignore
public void testMessageHistoryWithHistoryPerformance() {
    ConfigurableApplicationContext acWithHistory = new ClassPathXmlApplicationContext("perfWithMessageHistory.xml", MessageHistoryIntegrationTests.class);
    ConfigurableApplicationContext acWithoutHistory = new ClassPathXmlApplicationContext("perfWithoutMessageHistory.xml", MessageHistoryIntegrationTests.class);
    SampleGateway gatewayHistory = acWithHistory.getBean("sampleGateway", SampleGateway.class);
    DirectChannel endOfThePipeChannelHistory = acWithHistory.getBean("endOfThePipeChannel", DirectChannel.class);
    endOfThePipeChannelHistory.subscribe(message -> {
        MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
        replyChannel.send(message);
    });
    SampleGateway gateway = acWithoutHistory.getBean("sampleGateway", SampleGateway.class);
    DirectChannel endOfThePipeChannel = acWithoutHistory.getBean("endOfThePipeChannel", DirectChannel.class);
    endOfThePipeChannel.subscribe(message -> {
        MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
        replyChannel.send(message);
    });
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    for (int i = 0; i < 10000; i++) {
        gatewayHistory.echo("hello");
    }
    stopWatch.stop();
    logger.info("Elapsed time with history 10000 calls: " + stopWatch.getTotalTimeSeconds());
    stopWatch = new StopWatch();
    stopWatch.start();
    for (int i = 0; i < 10000; i++) {
        gateway.echo("hello");
    }
    stopWatch.stop();
    logger.info("Elapsed time without history 10000 calls: " + stopWatch.getTotalTimeSeconds());
    acWithHistory.close();
    acWithoutHistory.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectChannel(org.springframework.integration.channel.DirectChannel) StopWatch(org.springframework.util.StopWatch) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 30 with StopWatch

use of org.springframework.util.StopWatch in project spring-integration by spring-projects.

the class AggregatorTests method testAggPerfDefaultPartial.

@Test
public void testAggPerfDefaultPartial() throws InterruptedException, ExecutionException, TimeoutException {
    AggregatingMessageHandler handler = new AggregatingMessageHandler(new DefaultAggregatingMessageGroupProcessor());
    handler.setCorrelationStrategy(message -> "foo");
    handler.setReleasePartialSequences(true);
    DirectChannel outputChannel = new DirectChannel();
    handler.setOutputChannel(outputChannel);
    final CompletableFuture<Collection<?>> resultFuture = new CompletableFuture<>();
    outputChannel.subscribe(message -> {
        Collection<?> payload = (Collection<?>) message.getPayload();
        logger.warn("Received " + payload.size());
        resultFuture.complete(payload);
    });
    SimpleMessageStore store = new SimpleMessageStore();
    SimpleMessageGroupFactory messageGroupFactory = new SimpleMessageGroupFactory(SimpleMessageGroupFactory.GroupType.BLOCKING_QUEUE);
    store.setMessageGroupFactory(messageGroupFactory);
    handler.setMessageStore(store);
    StopWatch stopwatch = new StopWatch();
    stopwatch.start();
    for (int i = 0; i < 120000; i++) {
        if (i % 10000 == 0) {
            stopwatch.stop();
            logger.warn("Sent " + i + " in " + stopwatch.getTotalTimeSeconds() + " (10k in " + stopwatch.getLastTaskTimeMillis() + "ms)");
            stopwatch.start();
        }
        handler.handleMessage(MessageBuilder.withPayload("foo").setSequenceSize(120000).setSequenceNumber(i + 1).build());
    }
    stopwatch.stop();
    logger.warn("Sent " + 120000 + " in " + stopwatch.getTotalTimeSeconds() + " (10k in " + stopwatch.getLastTaskTimeMillis() + "ms)");
    Collection<?> result = resultFuture.get(10, TimeUnit.SECONDS);
    assertNotNull(result);
    assertEquals(120000, result.size());
    // actually < 2.0, was many minutes
    assertThat(stopwatch.getTotalTimeSeconds(), lessThan(60.0));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SimpleMessageStore(org.springframework.integration.store.SimpleMessageStore) SimpleMessageGroupFactory(org.springframework.integration.store.SimpleMessageGroupFactory) DirectChannel(org.springframework.integration.channel.DirectChannel) Collection(java.util.Collection) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Aggregations

StopWatch (org.springframework.util.StopWatch)106 Test (org.junit.Test)45 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)12 ArrayList (java.util.ArrayList)10 ITestBean (org.springframework.tests.sample.beans.ITestBean)9 TestBean (org.springframework.tests.sample.beans.TestBean)9 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)7 List (java.util.List)6 Test (org.junit.jupiter.api.Test)6 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)6 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ApplicationMap (com.navercorp.pinpoint.web.applicationmap.ApplicationMap)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Ignore (org.junit.Ignore)5 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)5 Range (com.navercorp.pinpoint.web.vo.Range)4 Dataset (org.apache.jena.query.Dataset)4