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

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

Introduction

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

Prototype

public void start() 

Source Link

Document

Start the stopwatch.

This method starts a new timing session, clearing any previous values.

Usage

From source file:au.id.hazelwood.xmltvguidebuilder.config.ConfigFactory.java

public ConfigFactory() throws Exception {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    schema = schemaFactory.newSchema(new StreamSource(toInputStream("/config.xsd")));
    stopWatch.stop();/*from w  w  w .j  a v  a2 s.co m*/
    LOGGER.debug("ConfigFactory created in {}", formatDurationWords(stopWatch.getTime()));
}

From source file:eagle.storage.jdbc.entity.impl.JdbcEntityDeleterImpl.java

private int deleteByCriteria(Criteria criteria) throws Exception {
    String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString();
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    if (LOG.isDebugEnabled())
        LOG.debug("Deleting by query: " + displaySql);
    try {/* w  ww  . ja  v  a 2s.c  o m*/
        TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor();
        int result = peer.delegate().doDelete(criteria);
        LOG.info(String.format("Deleted %s records in %s ms (sql: %s)", result, stopWatch.getTime(),
                displaySql));
        return result;
    } catch (Exception e) {
        LOG.error("Failed to delete by query: " + displaySql, e);
        throw e;
    } finally {
        stopWatch.stop();
    }
}

From source file:adams.gui.tools.wekainvestigator.tab.associatetab.evaluation.AbstractAssociatorEvaluation.java

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

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

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 www  .java 2 s.  c  om
 * @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");
}

From source file:adams.gui.tools.wekainvestigator.tab.attseltab.evaluation.AbstractAttributeSelectionEvaluation.java

/**
 * Performs attribute selections and updates the result item.
 *
 * @param evaluator   the current evaluator
 * @param search    the current search/*from  w w w .j av a 2s.c o  m*/
 * @param item    the result item to update
 * @throws Exception   if evaluation fails
 */
public void evaluate(ASEvaluation evaluator, ASSearch search, ResultItem item) throws Exception {
    StopWatch watch;

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

From source file:InteropVirtuosoTest.java

@Test
@Ignore/*from w  w w .ja  v a 2 s  .com*/
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:au.id.hazelwood.xmltvguidebuilder.config.ConfigFactory.java

public Config create(File file) throws InvalidConfigException {
    try {//from w  ww .ja  v a  2  s  . c  o  m
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        LOGGER.debug("Validating config file {}", file);
        schema.newValidator().validate(new StreamSource(file));
        LOGGER.debug("Loading config file {}", file);
        HierarchicalConfiguration configuration = new XMLConfiguration(file);
        int offset = configuration.getInt("listing.offset");
        int days = configuration.getInt("listing.days");
        int synopsis = configuration.getInt("listing.synopsis");
        String regionId = configuration.getString("listing.regionId");
        Map<Integer, ChannelConfig> channelConfigById = loadChannelConfigs(configuration);
        Config config = new Config(offset, days, synopsis, regionId,
                new ArrayList<>(channelConfigById.values()));
        LOGGER.debug("Loaded {} from {} in {}", config, file, formatDurationWords(stopWatch.getTime()));
        return config;
    } catch (Throwable e) {
        throw new InvalidConfigException(e.getMessage(), e);
    }
}

From source file:eagle.storage.jdbc.entity.impl.JdbcEntityUpdaterImpl.java

@Override
public int update(List<E> entities) throws Exception {
    ConnectionManager cm = ConnectionManagerFactory.getInstance();
    TorqueStatementPeerImpl<E> peer = cm.getStatementExecutor(this.jdbcEntityDefinition.getJdbcTableName());
    Connection connection = cm.getConnection();
    connection.setAutoCommit(false);/*from  w w  w  .  ja  v a  2s . c  om*/

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    int num = 0;
    try {
        for (E entity : entities) {
            String primaryKey = entity.getEncodedRowkey();
            PrimaryKeyCriteriaBuilder pkBuilder = new PrimaryKeyCriteriaBuilder(Arrays.asList(primaryKey),
                    this.jdbcEntityDefinition.getJdbcTableName());
            Criteria selectCriteria = pkBuilder.build();
            if (LOG.isDebugEnabled())
                LOG.debug("Updating by query: " + SqlBuilder.buildQuery(selectCriteria).getDisplayString());
            ColumnValues columnValues = JdbcEntitySerDeserHelper.buildColumnValues(entity,
                    this.jdbcEntityDefinition);
            num += peer.delegate().doUpdate(selectCriteria, columnValues, connection);
        }
        if (LOG.isDebugEnabled())
            LOG.debug("Committing updates");
        connection.commit();
    } catch (Exception ex) {
        LOG.error("Failed to update, rolling back", ex);
        connection.rollback();
        throw ex;
    } finally {
        stopWatch.stop();
        if (LOG.isDebugEnabled())
            LOG.debug("Closing connection");
        connection.close();
    }
    LOG.info(String.format("Updated %s records in %s ms", num, stopWatch.getTime()));
    return num;
}

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

@Test
public void hello() throws FileNotFoundException, IOException {

    StopWatch sw = new StopWatch();
    sw.start();

    Path p = Paths.get("/Users/gaignard-a/Desktop/access.log-20150818");
    String label = p.getFileName().toString();
    System.out.println();//from   w w  w.  ja  v  a2  s.  c  o m

    FileInputStream fis = new FileInputStream(p.toFile());
    String sha512 = DigestUtils.sha512Hex(fis);
    System.out.println("");
    System.out.println(sha512);
    System.out.println("SHA512 calculated in " + sw.getTime() + " ms.");

    StringBuffer sb = new StringBuffer();
    sb.append("@base         <http://fr.symetric> .\n" + "@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .\n"
            + "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n" + "@prefix sioc: <http://rdfs.org/sioc/ns#> .\n"
            + "@prefix prov: <http://www.w3.org/ns/prov#> .\n"
            + "@prefix sym:   <http://fr.symetric/vocab#> .\n"
            + "@prefix dcterms: <http://purl.org/dc/terms/> .\n"
            + "@prefix tavernaprov:  <http://ns.taverna.org.uk/2012/tavernaprov/> .\n"
            + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n");

    sb.append("<#" + UUID.randomUUID().toString() + ">\n" + "\t a prov:Entity ;\n");
    sb.append("\t rdfs:label \"" + label + "\"^^xsd:String ;\n");
    sb.append("\t tavernaprov:sha512 \"" + sha512 + "\"^^xsd:String .");

    System.out.println("");
    System.out.println("");
    System.out.println(sb.toString());

    fis.close();

}

From source file:au.id.hazelwood.xmltvguidebuilder.runner.App.java

public void run(File configFile, File outFile) throws InvalidConfigException, JAXBException, IOException {
    LOGGER.info("Running XMLTV Guide Builder");
    StopWatch watch = new StopWatch();
    watch.start();

    LOGGER.info("Reading config file '{}'", configFile.getCanonicalPath());
    Config config = configFactory.create(configFile);
    DateTime today = new DateTime().withTimeAtStartOfDay();
    DateTime from = today.plusDays(config.getOffset());
    DateTime to = from.plusDays(config.getDays());

    LOGGER.info("Getting listing from foxtel grabber between {} and {}", toISODateTime(from),
            toISODateTime(to));/* w  w w.  ja  va 2  s .com*/
    ChannelListings channelListings = grabber.getListing(config, from, to, config.getChannelConfigs());

    LOGGER.info("Verifying listings for all channels between {} and {}",
            new Object[] { toISODateTime(from), toISODateTime(to) });
    DateTime subsetTo = from.plusDays(7).isBefore(to) ? from.plusDays(7) : to;
    listingVerifier.verifyListing(channelListings, from, to, subsetTo);

    LOGGER.info("Backup old output files");
    backupOldOutputFiles(outFile);

    LOGGER.info("Writing result to {}", outFile.getCanonicalPath());
    Writer writer = new BufferedWriter(new FileWriterWithEncoding(outFile, "UTF-8"));
    bindingService.marshal(xmltvMapper.toXmltv(channelListings), writer);
    IOUtils.closeQuietly(writer);

    watch.stop();
    LOGGER.info("XMLTV Guide Builder successful in {}", formatDurationWords(watch.getTime()));
}