Search in sources :

Example 41 with StopWatch

use of org.springframework.util.StopWatch in project Gemma by PavlidisLab.

the class DifferentialExpressionSearchTaskImpl method fetchDifferentialExpressionResults.

/**
 * Main processing: fetch diff ex results.
 *
 * @param resultSets   to be searched
 * @param geneIds      to be searched
 * @param searchResult holds the results
 */
private void fetchDifferentialExpressionResults(List<DiffExResultSetSummaryValueObject> resultSets, List<Long> geneIds, DifferentialExpressionGenesConditionsValueObject searchResult) {
    StopWatch watch = new StopWatch("Process differential expression search");
    watch.start("Fetch diff ex results");
    // Main query for results; the main time sink.
    Map<Long, Map<Long, DiffExprGeneSearchResult>> resultSetToGeneResults = differentialExpressionResultService.findDiffExAnalysisResultIdsInResultSets(resultSets, geneIds);
    watch.stop();
    Collection<DiffExprGeneSearchResult> aggregatedResults = this.aggregateAcrossResultSets(resultSetToGeneResults);
    watch.start("Fetch details for contrasts for " + aggregatedResults.size() + " results");
    Map<Long, ContrastsValueObject> detailedResults = this.getDetailsForContrasts(aggregatedResults);
    this.processHits(searchResult, resultSetToGeneResults, resultSets, detailedResults);
    watch.stop();
    DifferentialExpressionSearchTaskImpl.log.info("Diff ex search finished:\n" + watch.prettyPrint());
}
Also used : StopWatch(org.springframework.util.StopWatch)

Example 42 with StopWatch

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

the class FilterChainPerformanceTests method provideDataOnScalingWithNumberOfAuthoritiesUserHas.

/**
 * Creates data from 1 to N_AUTHORITIES in steps of 10, performing N_INVOCATIONS for
 * each
 */
@Test
public void provideDataOnScalingWithNumberOfAuthoritiesUserHas() throws Exception {
    StopWatch sw = new StopWatch("Scaling with nAuthorities");
    for (int user = 0; user < N_AUTHORITIES / 10; user++) {
        int nAuthorities = (user != 0) ? user * 10 : 1;
        SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken("bob", "bobspassword", createRoles(nAuthorities)));
        this.session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
        SecurityContextHolder.clearContext();
        sw.start(nAuthorities + " authorities");
        runWithStack(this.minimalStack);
        System.out.println(sw.shortSummary());
        sw.stop();
    }
    System.out.println(sw.prettyPrint());
}
Also used : UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) StopWatch(org.springframework.util.StopWatch) Test(org.junit.jupiter.api.Test)

Example 43 with StopWatch

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

the class PerformanceMonitorInterceptor method invokeUnderTrace.

@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
    String name = createInvocationTraceName(invocation);
    StopWatch stopWatch = new StopWatch(name);
    stopWatch.start(name);
    try {
        return invocation.proceed();
    } finally {
        stopWatch.stop();
        writeToLog(logger, stopWatch.shortSummary());
    }
}
Also used : StopWatch(org.springframework.util.StopWatch)

Example 44 with StopWatch

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

the class IntroductionBenchmarkTests method timeManyInvocations.

@Test
public void timeManyInvocations() {
    StopWatch sw = new StopWatch();
    TestBean target = new TestBean();
    ProxyFactory pf = new ProxyFactory(target);
    pf.setProxyTargetClass(false);
    pf.addAdvice(new SimpleCounterIntroduction());
    ITestBean proxy = (ITestBean) pf.getProxy();
    Counter counter = (Counter) proxy;
    sw.start(INVOCATIONS + " invocations on proxy, not hitting introduction");
    for (int i = 0; i < INVOCATIONS; i++) {
        proxy.getAge();
    }
    sw.stop();
    sw.start(INVOCATIONS + " invocations on proxy, hitting introduction");
    for (int i = 0; i < INVOCATIONS; i++) {
        counter.getCount();
    }
    sw.stop();
    sw.start(INVOCATIONS + " invocations on target");
    for (int i = 0; i < INVOCATIONS; i++) {
        target.getAge();
    }
    sw.stop();
    System.out.println(sw.prettyPrint());
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) TestBean(org.springframework.beans.testfixture.beans.TestBean) ITestBean(org.springframework.beans.testfixture.beans.ITestBean) StopWatch(org.springframework.util.StopWatch) Test(org.junit.jupiter.api.Test)

Example 45 with StopWatch

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

the class QuartzSchedulerLifecycleTests method destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang.

// SPR-6354
@Test
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", getClass());
    assertThat(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder")).isNotNull();
    StopWatch sw = new StopWatch();
    sw.start("lazyScheduler");
    context.close();
    sw.stop();
    assertThat(sw.getTotalTimeMillis() < 500).as("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis()).isTrue();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) StopWatch(org.springframework.util.StopWatch) Test(org.junit.jupiter.api.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