Example usage for org.springframework.util StopWatch prettyPrint

List of usage examples for org.springframework.util StopWatch prettyPrint

Introduction

In this page you can find the example usage for org.springframework.util StopWatch prettyPrint.

Prototype

public String prettyPrint() 

Source Link

Document

Generate a string with a table describing all tasks performed.

Usage

From source file:org.focusns.common.web.performance.MonitorFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    ///*from   w  w  w.  j  av  a  2s  .co  m*/
    if (log.isTraceEnabled()) {
        //
        String requestDesc = getRequestDescription(request);
        StopWatch stopWatch = new StopWatch();
        stopWatch.start(requestDesc);
        //
        filterChain.doFilter(request, response);
        //
        stopWatch.stop();
        //
        log.trace(stopWatch.prettyPrint());
    } else {
        filterChain.doFilter(request, response);
    }
}

From source file:org.jsmiparser.SpringTest.java

@Test
public void testPperformance() {
    int times = 10000000;
    StopWatch stopWatch = new StopWatch();
    stopWatch.start("query for " + times + " times");

    for (int i = 0; i < times; i++) {
        getMib().getOidValues().find("snmpOutPkts");
    }/*  ww  w. j ava  2 s . co  m*/
    stopWatch.stop();
    System.out.println(stopWatch.prettyPrint());
}

From source file:com.emc.smartcomm.UregApplication.java

/**
 * @param register A SmartRegister instance 
 *//*w w w.  j  av  a2s .c o  m*/
public void uregApplication(SmartRegister register) {

    logger.info("Processing UREG Tranasctional Flow:");
    GrsiRequest greq = PopulateData.setGrsiRequest();
    GrsiResponse grsiResponse = PopulateData.setGrsiResponse();
    BabProtocolRequest breq = PopulateData.setBabRequest();
    BabProtocolResponse bres = PopulateData.setBabResponse();
    ValidateRegRequest vreg = PopulateData.setValidateRegRequest();
    ValidateRegResponse vres = PopulateData.setValidateRegResponse();
    greq.setSvcFlag(register.getChannel());
    String msg = register.toString();
    String path = "/appl/LogTransaction.txt";

    Timestamp txStartTime = PrepareLog.getCurrentTimeStamp();
    StopWatch sw = new StopWatch("UREG Transaction");
    sw.start("UREG Transaction");
    logger.debug("UREG Transaction Initiated:{}", txStartTime);
    StopWatch sw0 = new StopWatch("UREG REQUEST");
    sw0.start("UREG REQUEST");
    uregTemplate.convertAndSend(msg);
    sw0.stop();
    logger.debug(sw0.prettyPrint());
    logger.debug(sw0.shortSummary());

    StopWatch sw1 = new StopWatch("GRSI Request");
    sw1.start("GRSI Request");
    grsiTemplate.convertAndSend(greq);
    sw1.stop();
    logger.debug(sw1.prettyPrint());
    logger.debug(sw1.shortSummary());

    if ("PVS".equals(grsiResponse.getsx12())) // || "BAB".equals(grsiResponse.getsx13()))
    {
        StopWatch sw2 = new StopWatch("Validate Request:");
        sw2.start("Validate Request:");
        String validateRegText = vreg.toString();
        validateRegTemplate.convertAndSend(validateRegText);
        sw2.stop();
        logger.debug(sw2.prettyPrint());
        logger.debug(sw2.shortSummary());
    }

    if ("PPC".equals(grsiResponse.getsx03())) {

        StopWatch sw3 = new StopWatch("BAB Request");
        sw3.start("BAB Request:");
        babTemplate.convertAndSend("bab.Request", breq.toString());
        sw3.stop();
        logger.debug(sw3.prettyPrint());
        logger.debug(sw3.shortSummary());
    }

    grsiResponse.setsx03("NSN");
    if ("NSN".equals(grsiResponse.getsx03())) {

        InputStream is = getClass().getResourceAsStream("/mock/SOAPProtocolRecharge.txt");
        String message = FileReader.readFile(is);
        StopWatch sw4 = new StopWatch("SOAP Recharge Request: ");
        sw4.start("SOAP Recharge Request:");
        soapRechargeTemplate.convertAndSend(message);
        sw4.stop();
        logger.debug(sw4.prettyPrint());
        logger.debug(sw4.shortSummary());

    }

    Timestamp txEndTime = PrepareLog.getCurrentTimeStamp();
    logger.debug("Persisting Transaction log in gemxd and oracle");
    LogTransaction logTransaction = PrepareLog.prepareLog(greq, grsiResponse, breq, bres, vreg, vres);
    logTransaction.setTxnStartTime(txStartTime);
    logTransaction.setTxnEndTime(txEndTime);
    StopWatch sw5 = new StopWatch("Transaction Persistence: ");
    sw5.start("Transaction Persistence:");
    logTransactionService.logTransaction(logTransaction);
    sw5.stop();
    logger.debug(sw5.prettyPrint());
    logger.debug(sw5.shortSummary());
    ExternalFileWriter.writeToFile(path, PopulateData.populateLog());

    sw.stop();
    logger.debug(sw.prettyPrint());
    logger.debug(sw.shortSummary());
    logger.debug("UREG Transaction is Completed:{}", txEndTime);
    logger.info("UREG Transaction TimeSpan:{}", (txEndTime.getTime() - txStartTime.getTime()));

}

From source file:org.apache.mina.springrpc.example.gettingstarted.AbstractHelloServiceClientTests.java

protected void invokeService(final HelloService service) {
    StopWatch sw = new StopWatch(
            "HelloService with concurrent [ " + useConcurrent + " ], runtimes [ " + RUN_TIMES + " ]");
    sw.start();//from ww  w.  j  av  a2s .  co  m

    List<Callable<HelloResponse>> tasks = createTasks(service);

    if (useConcurrent) {
        executeUseConcurrent(tasks);
    } else {
        execute(tasks);
    }

    sw.stop();
    logger.info(sw.prettyPrint());
}

From source file:com.excilys.ebi.spring.dbunit.DbUnitDatabasePopulator.java

@Override
public void populate(Connection connection) throws SQLException {

    LOGGER.debug("populating");

    StopWatch sw = new StopWatch("DbUnitDatabasePopulator");

    DatabaseOperation operation = phase.getOperation(dataSetConfiguration);
    try {// ww  w.j  av  a 2  s  .c o  m
        IDataSet dataSet = decorateDataSetIfNeeded(dataSetConfiguration.getDataSet(),
                dataSetConfiguration.getDecorators());
        String schema = dataSetConfiguration.getSchema();
        DatabaseConnection databaseConnection = getDatabaseConnection(connection, schema, dataSetConfiguration);
        sw.start("populating");
        operation.execute(databaseConnection, dataSet);
        sw.stop();
        LOGGER.debug(sw.prettyPrint());

    } catch (BatchUpdateException e) {
        LOGGER.error("BatchUpdateException while loading dataset", e);
        LOGGER.error("Caused by : ", e.getNextException());
        throw e;

    } catch (DatabaseUnitException e) {
        throw new DbUnitException(e);
    } catch (IOException e) {
        throw new DbUnitException(e);
    }
}

From source file:fr.acxio.tools.agia.alfresco.MultiLineNodeListItemReaderTest.java

@Test
@DirtiesContext//from   w w  w.j  a  v a 2s . c  o  m
public void testReadMixedIndex() throws Exception {
    StopWatch aStopWatch = new StopWatch("testReadMixedIndex");
    aStopWatch.start("Read first value");

    List<FieldSet> aRecord = multiLineNodeListItemReader.read();
    assertNotNull(aRecord);
    assertEquals(2, aRecord.size());

    aStopWatch.stop();
    aStopWatch.start("Read 2nd value");

    aRecord = multiLineNodeListItemReader.read();
    assertNotNull(aRecord);
    assertEquals(1, aRecord.size());

    aStopWatch.stop();
    aStopWatch.start("Read 3rd value");

    aRecord = multiLineNodeListItemReader.read();
    assertNotNull(aRecord);
    assertEquals(2, aRecord.size());

    aStopWatch.stop();
    aStopWatch.start("Read 4th value");

    aRecord = multiLineNodeListItemReader.read();
    assertNotNull(aRecord);
    assertEquals(1, aRecord.size());

    aStopWatch.stop();
    aStopWatch.start("Read 5th value");

    aRecord = multiLineNodeListItemReader.read();
    assertNull(aRecord);

    aStopWatch.stop();
    System.out.println(aStopWatch.prettyPrint());
}

From source file:fr.acxio.tools.agia.alfresco.configuration.SimpleNodeFactoryTest.java

@Test
public void testConditionalTreeGetNodes() throws Exception {
    FolderDefinition aDefaultNodeDefinition = NodeFactoryUtils.createFolderDefinition("test", null, null, null);
    FolderDefinition aFolder1NodeDefinition = NodeFactoryUtils.createFolderDefinition("s1", null, "true", null);
    FolderDefinition aFolder2NodeDefinition = NodeFactoryUtils.createFolderDefinition("s2", null, "false",
            null);/*  w w  w. j av a  2s.c  om*/
    FolderDefinition aFolder3NodeDefinition = NodeFactoryUtils.createFolderDefinition("s3", null, "true", null);

    aDefaultNodeDefinition.addFolder(aFolder1NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder2NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder3NodeDefinition);

    DocumentDefinition aDocument1Definition = NodeFactoryUtils.createDocumentDefinition("doc1", null, null,
            null, null, null);
    DocumentDefinition aDocument2Definition = NodeFactoryUtils.createDocumentDefinition("doc2", null, null,
            null, null, null);
    DocumentDefinition aDocument3Definition = NodeFactoryUtils.createDocumentDefinition("doc3", null, null,
            null, null, null);

    aFolder1NodeDefinition.addDocument(aDocument1Definition);
    aFolder1NodeDefinition.addDocument(aDocument2Definition);
    aFolder2NodeDefinition.addDocument(aDocument3Definition);

    StopWatch aStopWatch = new StopWatch("testConditionalTreeGetNodes");
    aStopWatch.start("Create a node list");

    SimpleNodeFactory aNodeFactory = new SimpleNodeFactory();
    aNodeFactory.setNamespaceContext(namespaceContext);
    aNodeFactory.setNodeDefinition(aDefaultNodeDefinition);
    NodeList aNodeList = aNodeFactory.getNodes(evaluationContext);

    aStopWatch.stop();

    assertEquals(5, aNodeList.size());
    assertEquals("/cm:test", ((Folder) aNodeList.get(0)).getPath());
    assertEquals("/cm:test/cm:s1", ((Folder) aNodeList.get(1)).getPath());
    assertEquals("/cm:test/cm:s1/cm:doc1", ((Document) aNodeList.get(2)).getPath());
    assertEquals("/cm:test/cm:s1/cm:doc2", ((Document) aNodeList.get(3)).getPath());
    assertEquals("/cm:test/cm:s3", ((Folder) aNodeList.get(4)).getPath());

    System.out.println(aStopWatch.prettyPrint());
}

From source file:edu.isistan.carcha.lsa.LSARunner.java

/**
 * Discover traceability./*from  w w w .jav a2  s  . co  m*/
 *
 * @param sspaceFile the sspace file
 * @return the traceability document
 * @throws IOException Signals that an I/O exception has occurred.
 */
private TraceabilityDocument discoverTraceability(File sspaceFile) throws IOException {

    TraceabilityDocument ret = new TraceabilityDocument(concerns, designDecision);
    List<TraceabilityLink> links = new ArrayList<TraceabilityLink>();

    StaticSemanticSpace sspace = new StaticSemanticSpace(sspaceFile);

    //build the document vector to compare sentences
    DocumentVectorBuilder builder = new DocumentVectorBuilder(sspace);

    StopWatch sw = new StopWatch();
    sw.start("LSA - Traceability discovery");

    int untracedCount = 0;
    for (Entity req : concerns) {
        //create vector1
        DoubleVector vector1 = builder.buildVector(
                new BufferedReader(new StringReader(req.getFormattedLabel())), new CompactSparseVector());

        boolean hasTrace = false;
        for (Entity arch : designDecision) {
            //create vector2
            DoubleVector vector2 = builder.buildVector(
                    new BufferedReader(new StringReader(arch.getFormattedLabel())), new CompactSparseVector());

            //Math round is WAY faster than DoubleFormat
            Double linkWeight = ((double) Math.round(Similarity.cosineSimilarity(vector1, vector2) * 100)
                    / 100);

            //add the edge between the two nodes including the calculated weight
            if (linkWeight > threshold) {
                links.add(new TraceabilityLink(req, arch, linkWeight));
                hasTrace = true;
            }
        }
        if (!hasTrace) {
            untracedCount++;
        }
    }
    sw.stop();
    logger.info(sw.prettyPrint());

    //save the traceability results like: untraced count, links, traced count, etc...
    ret.setLinks(links);
    ret.setUntracedConcernCount(untracedCount);
    ret.setTracedConcernCount(concerns.size() - untracedCount);
    return ret;
}

From source file:fr.acxio.tools.agia.alfresco.configuration.SimpleNodeFactoryTest.java

@Test
public void testGetNodes() throws Exception {
    FolderDefinition aDefaultNodeDefinition = NodeFactoryUtils.createFolderDefinition("test", null, null, null);

    //      FieldSet aData = new DefaultFieldSet(new String[]{"A", "B", "C"}, new String[]{"A", "B", "C"});

    StopWatch aStopWatch = new StopWatch("testGetNodes");
    aStopWatch.start("Create a node list");

    SimpleNodeFactory aNodeFactory = new SimpleNodeFactory();
    aNodeFactory.setNamespaceContext(namespaceContext);
    aNodeFactory.setNodeDefinition(aDefaultNodeDefinition);
    NodeList aNodeList = aNodeFactory.getNodes(evaluationContext);

    aStopWatch.stop();//w  w  w .  j a va2 s  .  c  o  m

    assertNotNull(aNodeList);
    assertEquals(1, aNodeList.size());
    assertTrue(aNodeList.get(0) instanceof Folder);
    Folder aFolder = (Folder) aNodeList.get(0);
    assertEquals("test", aFolder.getName());
    assertNotNull(aFolder.getAspects());
    assertEquals(0, aFolder.getAspects().size());
    assertNotNull(aFolder.getAssociations());
    assertEquals(0, aFolder.getAssociations().size());
    assertNotNull(aFolder.getFolders());
    assertEquals(0, aFolder.getFolders().size());
    assertNotNull(aFolder.getDocuments());
    assertEquals(0, aFolder.getDocuments().size());
    assertNull(aFolder.getParent());
    assertEquals("/cm:test", aFolder.getPath());
    assertNotNull(aFolder.getType());
    assertEquals("{http://www.alfresco.org/model/content/1.0}folder", aFolder.getType().toString());

    System.out.println(aStopWatch.prettyPrint());
}

From source file:org.fracturedatlas.athena.helper.ticketfactory.manager.TicketFactoryManager.java

public List<Ticket> createTickets(PTicket pTicket) {
    String performanceId = (String) pTicket.getId();
    PTicket performance = athenaStage.get("performance", performanceId);

    //If the performace isn't found, throw a bad request
    if (performance == null) {
        throw new AthenaException("Performance with id [" + performanceId + "] was not found");
    }/* ww  w. ja va 2 s  .c  o  m*/

    StopWatch watch = new StopWatch();
    watch.start("gathering info");

    String chartId = performance.get("chartId");
    String eventId = performance.get("eventId");
    PTicket chart = athenaStage.get("chart", chartId);
    PTicket event = athenaStage.get("event", eventId);

    AthenaSearchConstraint sectionSearch = new AthenaSearchConstraint("chartId", Operator.EQUALS, chartId);
    AthenaSearch athenaSearch = new AthenaSearch.Builder(sectionSearch).build();
    logger.debug("Finding sections for chart [{}]", chartId);
    Collection<PTicket> sections = athenaStage.find("section", athenaSearch);
    logger.debug("Found [{}] sections", sections.size());

    ArrayList<Ticket> ticketsToCreate = new ArrayList<Ticket>();
    watch.stop();

    //for each section
    for (PTicket section : sections) {
        watch.start("section " + section.get("name"));
        Integer capacity = Integer.parseInt(section.get("capacity"));
        logger.debug("capacity of section [{}] is [{}]", section.getId(), capacity);
        for (int seatNum = 0; seatNum < capacity; seatNum++) {
            Ticket ticket = new Ticket(section, performance, event, INITIAL_STATE);
            ticketsToCreate.add(ticket);

        }
        watch.stop();
    }

    watch.start("creating tickets");
    List<Ticket> tickets = saveTickets(ticketsToCreate);
    watch.stop();
    logger.debug("{}", watch.prettyPrint());
    return tickets;
}