Example usage for org.apache.commons.lang.time StopWatch getTime

List of usage examples for org.apache.commons.lang.time StopWatch getTime

Introduction

In this page you can find the example usage for org.apache.commons.lang.time StopWatch getTime.

Prototype

public long getTime() 

Source Link

Document

Get the time on the stopwatch.

This is either the time between the start and the moment this method is called, or the amount of time between start and stop.

Usage

From source file:com.liferay.wiki.util.WikiCacheUtil.java

public static WikiPageDisplay getDisplay(long nodeId, String title, PortletURL viewPageURL,
        PortletURL editPageURL, String attachmentURLPrefix) {

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();/*from   w ww  .j  a  va  2  s.c om*/

    String key = _encodeKey(nodeId, title, viewPageURL.toString());

    WikiPageDisplay pageDisplay = (WikiPageDisplay) _portalCache.get(key);

    if (pageDisplay == null) {
        pageDisplay = _getPageDisplay(nodeId, title, viewPageURL, editPageURL, attachmentURLPrefix);

        if (pageDisplay != null) {
            PortalCacheHelperUtil.putWithoutReplicator(_portalCache, key, pageDisplay);
        }
    }

    if (_log.isDebugEnabled()) {
        _log.debug(StringBundler.concat("getDisplay for {", String.valueOf(nodeId), ", ", title, ", ",
                String.valueOf(viewPageURL), ", ", String.valueOf(editPageURL), "} takes ",
                String.valueOf(stopWatch.getTime()), " ms"));
    }

    return pageDisplay;
}

From source file:fr.cnrs.sharp.test.MainCLITest.java

@Test
public void Main1() throws IOException {
    InputStream is = MainCLITest.class.getClassLoader().getResourceAsStream("galaxy.prov.ttl");
    Path p = Files.createTempFile("test-prov", ".ttl");
    FileUtils.copyInputStreamToFile(is, p.toFile());
    System.out.println("Galaxy PROV written to " + p.toString());

    String[] params = { "-i", p.toString() };

    StopWatch sw = new StopWatch();
    sw.start();//from w ww.j  a va2 s .  co m
    Main.main(params);
    sw.stop();
    System.out.println("DONE in " + sw.getTime() + " ms");

}

From source file:fr.cnrs.sharp.test.MainCLITest.java

@Test
public void Main2() throws IOException {
    InputStream is = MainCLITest.class.getClassLoader().getResourceAsStream("galaxy.prov.ttl");
    Path p = Files.createTempFile("test-prov", ".ttl");
    FileUtils.copyInputStreamToFile(is, p.toFile());
    System.out.println("Galaxy PROV written to " + p.toString());

    String[] params = { "-i", p.toString(), "-s" };

    StopWatch sw = new StopWatch();
    sw.start();/*  w w  w .  j a va  2s  . c o m*/
    Main.main(params);
    sw.stop();
    System.out.println("DONE in " + sw.getTime() + " ms");

}

From source file:com.icantrap.collections.dawg.TrieValidationTest.java

@Before
public void before() throws IOException {
    assumeThat(System.getProperty("RUN_VALIDATION"), is("on"));
    LineIterator iter = IOUtils.lineIterator(getClass().getResourceAsStream("/TWL06.txt"), null);
    dawgBuilder = new DawgBuilder();

    while (iter.hasNext())
        dawgBuilder.add(iter.next());/*from  ww  w  .j a va 2  s.  co m*/

    LineIterator.closeQuietly(iter);

    System.out.println("Uncompressed:  " + dawgBuilder.nodeCount() + " nodes");

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    dawgBuilder.build();
    stopWatch.stop();

    System.out.println("Time to compress:  " + stopWatch.getTime() + " ms.");
    System.out.println("Compressed:  " + dawgBuilder.nodeCount() + " nodes");
}

From source file:com.redhat.rhn.taskomatic.task.test.ErrataCacheTaskTest.java

public void aTestExecute() throws Exception {
    StopWatch sw = new StopWatch();

    ErrataCacheTask ect = new ErrataCacheTask();

    sw.start();//  ww w .  j  a  v  a  2  s . c om
    ect.execute(null);
    sw.stop();
    System.out.println("ErrataCacheTask took [" + sw.getTime() + "]");
}

From source file:au.id.hazelwood.xmltvguidebuilder.binding.BindingService.java

public void marshal(Object obj, Writer writer) throws JAXBException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from   www . ja va2s  .c o  m
    marshaller.marshal(obj, writer);
    stopWatch.stop();
    LOGGER.debug("Marshaled object in {}", formatDurationWords(stopWatch.getTime()));
}

From source file:de.unisb.cs.st.javalanche.mutation.hibernate.CoverageDataTest.java

public void testHugeCoverageDataSerialize() {
    Map<Long, Set<String>> map = getCoverageData();
    StopWatch stp = new StopWatch();
    stp.start();/*from  ww w  .  ja v  a2  s .c om*/
    SerializeIo.serializeToFile(map, new File("/Users/schuler/test.ser"));
    stp.stop();
    System.out.println("TIME " + stp.getTime());
}

From source file:de.unisb.cs.st.javalanche.mutation.hibernate.CoverageDataTest.java

@Test
public void testHugeCoverageDataSerialize2() {
    Map<Long, Set<String>> map = getCoverageData();
    StopWatch stp = new StopWatch();
    stp.start();/*from   w  ww  . j a v  a  2 s.co m*/
    MutationCoverageFile.saveCoverageData(map);
    stp.stop();
    System.out.println("Saving coverage data took:" + stp.getTime());
    MutationCoverageFile.reset();
    Mutation m = new Mutation("dummy", "dummy", 1, 1, MutationType.ARITHMETIC_REPLACE);
    m.setId(10l);
    Set<String> coverageData = MutationCoverageFile.getCoverageData(m);
    Set<String> tests = getTests();
    assertEquals(tests.size(), coverageData.size());
    for (String test : coverageData) {
        assertTrue(tests.contains((test)));
    }

}

From source file:InteropVirtuosoTest.java

@Test
@Ignore//  w w w  .j a va2  s. c o  m
public void fedQuery() throws URISyntaxException, MalformedURLException, IOException, EngineException {

    String query = "PREFIX idemo:<http://rdf.insee.fr/def/demo#>\n"
            + "PREFIX igeo:<http://rdf.insee.fr/def/geo#> \n" + "SELECT ?nom ?popTotale WHERE { \n"
            + "    ?region igeo:codeRegion \"24\" .\n" + "    ?region igeo:subdivisionDirecte ?departement .\n"
            + "    ?departement igeo:nom ?nom .\n" + "    ?departement idemo:population ?popLeg .\n"
            + "    ?popLeg idemo:populationTotale ?popTotale .\n" + "} ORDER BY ?popTotale";

    Graph graph = Graph.create();
    QueryProcessDQP exec = QueryProcessDQP.create(graph);
    exec.addRemote(new URL("http://localhost:" + 8890 + "/sparql"), WSImplem.REST);
    exec.addRemote(new URL("http://localhost:" + 8891 + "/kgram/sparql"), WSImplem.REST);
    //        exec.addRemote(new URL("http://localhost:" + 8892 + "/kgram/sparql"), WSImplem.REST);

    StopWatch sw = new StopWatch();
    sw.start();
    Mappings map = exec.query(query);
    int dqpSize = map.size();
    System.out.println("--------");
    long time = sw.getTime();
    System.out.println("Results in " + time + "ms");
    System.out.println("Results size " + dqpSize);
    System.out.println("");
    Assert.assertEquals(6, map.size());
}

From source file:adams.gui.tools.wekainvestigator.tab.clustertab.evaluation.AbstractClustererEvaluation.java

/**
 * Evaluates the clusterer and updates the result item.
 *
 * @param clusterer   the current clusterer
 * @param item   the item to update/*from w  ww. j  a va 2  s .c o  m*/
 * @throws Exception   if evaluation fails
 */
public void evaluate(Clusterer clusterer, ResultItem item) throws Exception {
    StopWatch watch;

    watch = new StopWatch();
    watch.start();
    doEvaluate(clusterer, item);
    watch.stop();
    if (item.hasRunInformation())
        item.getRunInformation().add("Total time", (watch.getTime() / 1000.0) + "s");
}