Package org.springframework.util

Examples of org.springframework.util.StopWatch


    rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
    rbd.getPropertyValues().addPropertyValue("spouse", new RuntimeBeanReference("spouse"));
    lbf.registerBeanDefinition("test", rbd);
    lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
    TestBean spouse = (TestBean) lbf.getBean("spouse");
    StopWatch sw = new StopWatch();
    sw.start("prototype");
    for (int i = 0; i < 100000; i++) {
      TestBean tb = (TestBean) lbf.getBean("test");
      assertSame(spouse, tb.getSpouse());
    }
    sw.stop();
    // System.out.println(sw.getTotalTimeMillis());
    assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
  }
View Full Code Here


    testLookupOverrideMethodsWithSetterInjection(xbf, "overrideInheritedMethod", true);

    // Check cost of repeated construction of beans with method overrides
    // Will pick up misuse of CGLIB
    int howMany = 100;
    StopWatch sw = new StopWatch();
    sw.start("Look up " + howMany + " prototype bean instances with method overrides");
    for (int i = 0; i < howMany; i++) {
      testLookupOverrideMethodsWithSetterInjection(xbf, "overrideOnPrototype", false);
    }
    sw.stop();
    System.out.println(sw);
    if (!LogFactory.getLog(DefaultListableBeanFactory.class).isDebugEnabled()) {
      assertTrue(sw.getTotalTimeMillis() < 2000);
    }

    // Now test distinct bean with swapped value in factory, to ensure the two are independent
    OverrideOneMethod swappedOom = (OverrideOneMethod) xbf.getBean("overrideOneMethodSwappedReturnValues");
View Full Code Here

    this.imageDatabase = imageDatabase;
  }

  public void listImages(int nrOfCalls) throws IOException {
    List images = this.imageDatabase.getImages();
    StopWatch stopWatch = new StopWatch();
    for (Iterator it = images.iterator(); it.hasNext();) {
      ImageDescriptor image = (ImageDescriptor) it.next();
      stopWatch.start(image.getName());
      ByteArrayOutputStream os = null;
      for (int i = 0; i < nrOfCalls; i++) {
        os = new ByteArrayOutputStream();
        this.imageDatabase.streamImage(image.getName(), os);
      }
      stopWatch.stop();
      System.out.println("Found image '" + image.getName() + "' with content size " + os.size() +
          " and description length " + image.getDescriptionLength());
    }
    System.out.println(stopWatch.prettyPrint());
  }
View Full Code Here

  public WorkflowStarterClient(ListableBeanFactory beanFactory) {
    this.beanFactory = beanFactory;
  }

  public void invokeOrderServices(int orderId, int nrOfCalls) throws RpException{
    StopWatch stopWatch = new StopWatch(nrOfCalls + " OrderService call(s)");
    Map orderServices = this.beanFactory.getBeansOfType(JaxRpcWorkflowStarter.class);
    for (Iterator it = orderServices.keySet().iterator(); it.hasNext();) {
      String beanName = (String) it.next();
      JaxRpcWorkflowStarter orderService = (JaxRpcWorkflowStarter) orderServices.get(beanName);
      System.out.println("Calling OrderService '" + beanName + "' with order ID " + orderId);
      stopWatch.start(beanName);
      String order = null;
      for (int i = 0; i < nrOfCalls; i++) {
        //order = orderService.startWorkflow();
      }
      stopWatch.stop();
      if (order != null) {
        log.debug("Return Value:"+order);
      }
      else {
        System.out.println("Order with ID " + orderId + " not found");
      }
      System.out.println();
    }
    System.out.println(stopWatch.prettyPrint());
  }
View Full Code Here

    public static void oneTimeSetUp() throws Exception {
        try {
            JahiaSite site = TestHelper.createSite(TESTSITE_NAME);
            JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Object>() {
                public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                    StopWatch stopWatch = new StopWatch("oneTimeSetUp");
                    stopWatch.start(Thread.currentThread().getName() + " creating set up nodes");
                    int pagesCreated = TestHelper.createSubPages(session.getNode(SITECONTENT_ROOT_NODE), 3, NB_CHILDREN);
                    logger.info("Created " + pagesCreated + " page hierarchy.");
                    session.save();
                    stopWatch.stop();
                    logger.error(stopWatch.prettyPrint());
                    return null;
                }
            });
            Assert.assertNotNull(site);
        } catch (Exception ex) {
View Full Code Here

    @Test
    public void testCreateManyChildUnstructuredNodes() throws RepositoryException {
        JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Object>() {
            public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                StopWatch stopWatch = new StopWatch("testCreateManyChildUnstructuredNodes");
                stopWatch.start(Thread.currentThread().getName() + " creating unstructured nodes");
                JCRNodeWrapper currentNode = session.getNode(SITECONTENT_ROOT_NODE);
                Node node = currentNode.addNode("testnodeUnstructured", "nt:unstructured");
                for (int i = 0; i < CHILD_COUNT; i++) {
                    node.addNode("node" + i, "nt:unstructured");
                }
                session.save();
                stopWatch.stop();
                logger.error(stopWatch.prettyPrint());
                return null;
            }
        });
    }
View Full Code Here

    @Test
    public void testCreateManyChildPageNodes() throws RepositoryException {
        JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<Object>() {
            public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                StopWatch stopWatch = new StopWatch("testCreateManyChildPageNodes");
                stopWatch.start(Thread.currentThread().getName() + " creating page nodes");
                JCRNodeWrapper currentNode = session.getNode(SITECONTENT_ROOT_NODE);
                Node node = currentNode.addNode("testPageNode", "jnt:page");
                for (int i = 0; i < CHILD_COUNT; i++) {
                    node.addNode("child" + Integer.toString(i), "jnt:page");
                }
                session.save();
                stopWatch.stop();
                logger.error(stopWatch.prettyPrint());
                return null;
            }
        });
    }
View Full Code Here

    @Test
    public void testConcurrentRead() throws InterruptedException, ExecutionException {
        ExecutorService executor = Executors.newFixedThreadPool(300);
        ExecutorCompletionService<Boolean> service = new ExecutorCompletionService<Boolean>(executor);
        StopWatch stopWatch = new StopWatch("testConcurrentRead");
        stopWatch.start(Thread.currentThread().getName() + " only reading nodes");
        for (int i = 0; i < 1000; i++) {
            service.submit(new Reader(), Boolean.TRUE);
        }
        for (int i = 0; i < 1000; i++) {
            Boolean aBoolean = service.take().get();
        }
        stopWatch.stop();
        logger.error(stopWatch.prettyPrint());
        executor.shutdown();
    }
View Full Code Here

    @Test
    public void testConcurrentReadWrite10Percent() throws InterruptedException, ExecutionException {
        ExecutorService executor = Executors.newFixedThreadPool(300);
        ExecutorCompletionService<Boolean> service = new ExecutorCompletionService<Boolean>(executor);
        StopWatch stopWatch = new StopWatch("testConcurrentReadWrite10Percent");
        stopWatch.start(Thread.currentThread().getName() + " reading // writing nodes (10% writers)");
        for (int i = 0; i < 1000; i++) {
            if (i % 10 == 0) {
                service.submit(new Writer("jnt:page"), Boolean.TRUE);
            } else {
                service.submit(new Reader(), Boolean.TRUE);
            }
        }
        for (int i = 0; i < 1000; i++) {
            Boolean aBoolean = service.take().get();
        }
        stopWatch.stop();
        logger.error(stopWatch.prettyPrint());
        executor.shutdown();
    }
View Full Code Here

    @Test
    public void testConcurrentReadWrite1Percent() throws InterruptedException, ExecutionException {
        ExecutorService executor = Executors.newFixedThreadPool(300);
        ExecutorCompletionService<Boolean> service = new ExecutorCompletionService<Boolean>(executor);
        StopWatch stopWatch = new StopWatch("testConcurrentReadWrite1Percent");
        stopWatch.start(Thread.currentThread().getName() + " reading // writing nodes (1% writers)");
        for (int i = 0; i < 1000; i++) {
            if (i % 100 == 0) {
                service.submit(new Writer("jnt:page"), Boolean.TRUE);
            } else {
                service.submit(new Reader(), Boolean.TRUE);
            }
        }
        for (int i = 0; i < 1000; i++) {
            Boolean aBoolean = service.take().get();
        }
        stopWatch.stop();
        logger.error(stopWatch.prettyPrint());
        executor.shutdown();
    }
View Full Code Here

TOP

Related Classes of org.springframework.util.StopWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.