Search in sources :

Example 6 with StopWatch

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

the class ServletRequestUtilsTests method testGetStringParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getStringParameter(request, "nonExistingParam", "defaultValue");
    }
    sw.stop();
    System.out.println(sw.getTotalTimeMillis());
    assertTrue("getStringParameter took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 250);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Example 7 with StopWatch

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

the class ServletRequestUtilsTests method testGetIntParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetIntParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getIntParameter(request, "nonExistingParam", 0);
    }
    sw.stop();
    System.out.println(sw.getTotalTimeMillis());
    assertTrue("getStringParameter took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 250);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Example 8 with StopWatch

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

the class ServletRequestUtilsTests method testGetBooleanParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getBooleanParameter(request, "nonExistingParam", false);
    }
    sw.stop();
    System.out.println(sw.getTotalTimeMillis());
    assertTrue("getStringParameter took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 250);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Example 9 with StopWatch

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

the class DefaultListableBeanFactoryTests method testPrototypeCreationWithDependencyCheckIsFastEnough.

@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    Assume.notLogging(factoryLog);
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
    lbf.registerBeanDefinition("test", rbd);
    lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor());
    StopWatch sw = new StopWatch();
    sw.start("prototype");
    for (int i = 0; i < 100000; i++) {
        lbf.getBean("test");
    }
    sw.stop();
    // System.out.println(sw.getTotalTimeMillis());
    assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
Also used : DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) LifecycleBean(org.springframework.tests.sample.beans.LifecycleBean) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Example 10 with StopWatch

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

the class DefaultListableBeanFactoryTests method testPrototypeCreationIsFastEnough.

@Test
public void testPrototypeCreationIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    Assume.notLogging(factoryLog);
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    lbf.registerBeanDefinition("test", rbd);
    StopWatch sw = new StopWatch();
    sw.start("prototype");
    for (int i = 0; i < 100000; i++) {
        lbf.getBean("test");
    }
    sw.stop();
    // System.out.println(sw.getTotalTimeMillis());
    assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000);
}
Also used : DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) 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