use of org.springframework.util.StopWatch in project spring-framework by spring-projects.
the class AnnotationProcessorPerformanceTests method testPrototypeCreationWithAutowiredPropertiesIsFastEnough.
@Test
public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() {
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
ctx.registerBeanDefinition("test", rbd);
ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
TestBean spouse = (TestBean) ctx.getBean("spouse");
StopWatch sw = new StopWatch();
sw.start("prototype");
for (int i = 0; i < 100000; i++) {
TestBean tb = (TestBean) ctx.getBean("test");
assertSame(spouse, tb.getSpouse());
}
sw.stop();
assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
use of org.springframework.util.StopWatch in project spring-framework by spring-projects.
the class DefaultConversionServiceTests method testPerformance1.
@Test
public void testPerformance1() {
Assume.group(TestGroup.PERFORMANCE);
StopWatch watch = new StopWatch("integer->string conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
for (int i = 0; i < 4000000; i++) {
conversionService.convert(3, String.class);
}
watch.stop();
watch.start("convert 4,000,000 manually");
for (int i = 0; i < 4000000; i++) {
new Integer(3).toString();
}
watch.stop();
// System.out.println(watch.prettyPrint());
}
use of org.springframework.util.StopWatch in project spring-framework by spring-projects.
the class GenericConversionServiceTests method testPerformance2.
@Test
public void testPerformance2() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
List<String> source = new LinkedList<>();
source.add("1");
source.add("2");
source.add("3");
TypeDescriptor td = new TypeDescriptor(getClass().getField("list"));
for (int i = 0; i < 1000000; i++) {
conversionService.convert(source, TypeDescriptor.forObject(source), td);
}
watch.stop();
watch.start("convert 4,000,000 manually");
for (int i = 0; i < 4000000; i++) {
List<Integer> target = new ArrayList<>(source.size());
for (String element : source) {
target.add(Integer.valueOf(element));
}
}
watch.stop();
// System.out.println(watch.prettyPrint());
}
use of org.springframework.util.StopWatch in project spring-framework by spring-projects.
the class GenericConversionServiceTests method testPerformance3.
@Test
public void testPerformance3() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
StopWatch watch = new StopWatch("map<string, string> -> map<string, integer> conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
Map<String, String> source = new HashMap<>();
source.put("1", "1");
source.put("2", "2");
source.put("3", "3");
TypeDescriptor td = new TypeDescriptor(getClass().getField("map"));
for (int i = 0; i < 1000000; i++) {
conversionService.convert(source, TypeDescriptor.forObject(source), td);
}
watch.stop();
watch.start("convert 4,000,000 manually");
for (int i = 0; i < 4000000; i++) {
Map<String, Integer> target = new HashMap<>(source.size());
for (Map.Entry<String, String> entry : source.entrySet()) {
target.put(entry.getKey(), Integer.valueOf(entry.getValue()));
}
}
watch.stop();
// System.out.println(watch.prettyPrint());
}
use of org.springframework.util.StopWatch in project pinpoint by naver.
the class FilteredMapServiceImpl method selectApplicationMap.
/**
* filtered application map
*/
@Override
public ApplicationMap selectApplicationMap(List<TransactionId> transactionIdList, Range originalRange, Range scanRange, Filter filter) {
if (transactionIdList == null) {
throw new NullPointerException("transactionIdList must not be null");
}
if (filter == null) {
throw new NullPointerException("filter must not be null");
}
StopWatch watch = new StopWatch();
watch.start();
final List<List<SpanBo>> filterList = selectFilteredSpan(transactionIdList, filter);
DotExtractor dotExtractor = createDotExtractor(scanRange, filterList);
ApplicationMap map = createMap(originalRange, scanRange, filterList);
ApplicationMapWithScatterScanResult applicationMapWithScatterScanResult = new ApplicationMapWithScatterScanResult(map, dotExtractor.getApplicationScatterScanResult());
watch.stop();
logger.debug("Select filtered application map elapsed. {}ms", watch.getTotalTimeMillis());
return applicationMapWithScatterScanResult;
}
Aggregations