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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations