Search in sources :

Example 66 with StopWatch

use of org.springframework.util.StopWatch in project pinpoint by naver.

the class MapServiceImpl method selectApplicationMap.

/**
     * Used in the main UI - draws the server map by querying the timeslot by time.
     */
@Override
public ApplicationMap selectApplicationMap(Application sourceApplication, Range range, SearchOption searchOption) {
    if (sourceApplication == null) {
        throw new NullPointerException("sourceApplication must not be null");
    }
    if (range == null) {
        throw new NullPointerException("range must not be null");
    }
    logger.debug("SelectApplicationMap");
    StopWatch watch = new StopWatch("ApplicationMap");
    watch.start("ApplicationMap Hbase Io Fetch(Caller,Callee) Time");
    LinkSelector linkSelector = new BFSLinkSelector(this.mapStatisticsCallerDao, this.mapStatisticsCalleeDao, hostApplicationMapDao, serverMapDataFilter);
    LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplication, range, searchOption);
    watch.stop();
    watch.start("ApplicationMap MapBuilding(Response) Time");
    ApplicationMapBuilder builder = new ApplicationMapBuilder(range);
    ApplicationMap map = builder.build(linkDataDuplexMap, agentInfoService, this.mapResponseDao);
    if (map.getNodes().isEmpty()) {
        map = builder.build(sourceApplication, agentInfoService);
    }
    watch.stop();
    if (logger.isInfoEnabled()) {
        logger.info("ApplicationMap BuildTime: {}", watch.prettyPrint());
    }
    if (serverMapDataFilter != null) {
        map = serverMapDataFilter.dataFiltering(map);
    }
    return map;
}
Also used : ApplicationMap(com.navercorp.pinpoint.web.applicationmap.ApplicationMap) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) StopWatch(org.springframework.util.StopWatch) ApplicationMapBuilder(com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder)

Example 67 with StopWatch

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

the class AbstractPropertyAccessorTests method setPrimitiveArrayPropertyLargeMatching.

@Test
public void setPrimitiveArrayPropertyLargeMatching() {
    Assume.group(TestGroup.PERFORMANCE);
    Assume.notLogging(LogFactory.getLog(AbstractPropertyAccessorTests.class));
    PrimitiveArrayBean target = new PrimitiveArrayBean();
    AbstractPropertyAccessor accessor = createAccessor(target);
    int[] input = new int[1024];
    StopWatch sw = new StopWatch();
    sw.start("array1");
    for (int i = 0; i < 1000; i++) {
        accessor.setPropertyValue("array", input);
    }
    sw.stop();
    assertEquals(1024, target.getArray().length);
    assertEquals(0, target.getArray()[0]);
    long time1 = sw.getLastTaskTimeMillis();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
    accessor.registerCustomEditor(String.class, new StringTrimmerEditor(false));
    sw.start("array2");
    for (int i = 0; i < 1000; i++) {
        accessor.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 125);
    accessor.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
    sw.start("array3");
    for (int i = 0; i < 1000; i++) {
        accessor.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
    accessor.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
    sw.start("array3");
    for (int i = 0; i < 1000; i++) {
        accessor.setPropertyValue("array", input);
    }
    sw.stop();
    assertTrue("Took too long", sw.getLastTaskTimeMillis() < 100);
    accessor.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
    sw.start("array4");
    for (int i = 0; i < 100; i++) {
        accessor.setPropertyValue("array", input);
    }
    sw.stop();
    assertEquals(1024, target.getArray().length);
    assertEquals(0, target.getArray()[0]);
    assertTrue("Took too long", sw.getLastTaskTimeMillis() > time1);
}
Also used : BigInteger(java.math.BigInteger) CustomNumberEditor(org.springframework.beans.propertyeditors.CustomNumberEditor) StringTrimmerEditor(org.springframework.beans.propertyeditors.StringTrimmerEditor) StopWatch(org.springframework.util.StopWatch) Test(org.junit.Test)

Example 68 with StopWatch

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

the class ServletRequestUtilsTests method testGetFloatParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getFloatParameter(request, "nonExistingParam", 0f);
    }
    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 69 with StopWatch

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

the class ServletRequestUtilsTests method testGetDoubleParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getDoubleParameter(request, "nonExistingParam", 0d);
    }
    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 70 with StopWatch

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

the class ServletRequestUtilsTests method testGetLongParameterWithDefaultValueHandlingIsFastEnough.

@Test
public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
    Assume.group(TestGroup.PERFORMANCE);
    MockHttpServletRequest request = new MockHttpServletRequest();
    StopWatch sw = new StopWatch();
    sw.start();
    for (int i = 0; i < 1000000; i++) {
        ServletRequestUtils.getLongParameter(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)

Aggregations

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