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

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

Introduction

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

Prototype

public long getTime() 

Source Link

Document

Get the time on the stopwatch.

Usage

From source file:net.sf.gazpachoquest.exporter.ExporterRunner.java

public static void main(final String... args) throws IOException {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("exporter-datasource-context.xml",
            "exporter-jpa-context.xml", "services-context.xml", "facades-context.xml",
            "components-context.xml");
    Exporter exporter = ctx.getBean(Exporter.class);
    StopWatch stopWatch = new StopWatch();
    logger.info("Exporting questionnaire definition");
    stopWatch.start();//from ww  w . jav  a  2s.c o  m
    exporter.doExport();
    stopWatch.stop();
    logger.info("Export process ended in {} {}", stopWatch.getTime(), "ms");
    ctx.close();
}

From source file:net.sf.gazpachoquest.importer.ImporterRunner.java

public static void main(final String... args) throws IOException {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("importer-datasource-context.xml",
            "importer-jpa-context.xml", "services-context.xml", "facades-context.xml",
            "components-context.xml");
    Importer populator = ctx.getBean(Importer.class);
    StopWatch stopWatch = new StopWatch();
    logger.info("Importing questionnaire definitions");
    stopWatch.start();/*from  www.  j a va  2 s .  c  o m*/
    populator.doImport();
    stopWatch.stop();
    logger.info("Import process ended in {} {}", stopWatch.getTime(), "ms");
    ctx.close();
}

From source file:net.sf.gazpachoquest.dbpopulator.DBPopulatorRunner.java

public static void main(final String... args) {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
            "dbpopulator-datasource-context.xml", "dbpopulator-jpa-context.xml", "services-context.xml",
            "facades-context.xml", "components-context.xml");
    DBPopulator populator = ctx.getBean(DBPopulator.class);
    StopWatch stopWatch = new StopWatch();
    logger.info("Populating database");
    stopWatch.start();/*from  ww w  .j  av a 2s .co  m*/
    ShiroLogin.login();
    populator.populate();
    stopWatch.stop();
    ShiroLogin.logout();
    logger.info("Database populated in {} {}", stopWatch.getTime(), "ms");

    ctx.close();
}

From source file:chibi.gemmaanalysis.cli.deprecated.AddExperimentalDesignCLI.java

/**
 * @param args/*w w w  . j  a v a2  s  .c om*/
 */
public static void main(String[] args) {
    AddExperimentalDesignCLI p = new AddExperimentalDesignCLI();
    StopWatch watch = new StopWatch();
    watch.start();
    try {
        Exception ex = p.doWork(args);
        if (ex != null) {
            ex.printStackTrace();
        }
        watch.stop();
        log.info("Total run time: " + watch.getTime());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:chibi.gemmaanalysis.MetaLinkFinderCli.java

/**
 * @param args// w  w  w  .  j a  va  2 s  .  c o m
 */
public static void main(String[] args) {
    MetaLinkFinderCli linkFinderCli = new MetaLinkFinderCli();
    StopWatch watch = new StopWatch();
    watch.start();
    try {
        Exception ex = linkFinderCli.doWork(args);
        if (ex != null) {
            ex.printStackTrace();
        }
        watch.stop();
        log.info(watch.getTime());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:chibi.gemmaanalysis.OutlierDetectionTestCli.java

/**
 * @param args/*from  w w w  .  ja va  2 s  . c  o  m*/
 */
public static void main(String[] args) {
    OutlierDetectionTestCli testCli = new OutlierDetectionTestCli();
    StopWatch watch = new StopWatch();
    watch.start();
    try {
        Exception ex = testCli.doWork(args);
        if (ex != null) {
            ex.printStackTrace();
        }
        watch.stop();
        log.info("Elapsed time: " + watch.getTime() / 1000 + " seconds");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    System.exit(0);
}

From source file:chibi.gemmaanalysis.AffyPlatFormAnalysisCli.java

/**
 * @param args//from   w w w.jav  a2 s .  c om
 */
public static void main(String[] args) {
    AffyPlatFormAnalysisCli analysis = new AffyPlatFormAnalysisCli();
    StopWatch watch = new StopWatch();
    watch.start();
    try {
        Exception ex = analysis.doWork(args);
        if (ex != null) {
            ex.printStackTrace();
        }
        watch.stop();
        log.info("Elapsed time: " + watch.getTime() / 1000 + " seconds");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:edu.jhu.hlt.concrete.gigaword.expt.ConvertGigawordDocuments.java

/**
 * @param args/*  w w  w .j  a v a2  s .com*/
 */
public static void main(String... args) {
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(Thread t, Throwable e) {
            logger.error("Thread {} caught unhandled exception.", t.getName());
            logger.error("Unhandled exception.", e);
        }
    });

    if (args.length != 2) {
        logger.info("Usage: {} {} {}", GigawordConcreteConverter.class.getName(), "path/to/expt/file",
                "path/to/out/folder");
        System.exit(1);
    }

    String exptPathStr = args[0];
    String outPathStr = args[1];

    // Verify path points to something.
    Path exptPath = Paths.get(exptPathStr);
    if (!Files.exists(exptPath)) {
        logger.error("File: {} does not exist. Re-run with the correct path to "
                + " the experiment 2 column file. See README.md.");
        System.exit(1);
    }

    logger.info("Experiment map located at: {}", exptPathStr);

    // Create output dir if not yet created.
    Path outPath = Paths.get(outPathStr);
    if (!Files.exists(outPath)) {
        logger.info("Creating directory: {}", outPath.toString());
        try {
            Files.createDirectories(outPath);
        } catch (IOException e) {
            logger.error("Caught an IOException when creating output dir.", e);
            System.exit(1);
        }
    }

    logger.info("Output directory located at: {}", outPathStr);

    // Read in expt map. See README.md.
    Map<String, Set<String>> exptMap = null;
    try (Reader r = ExperimentUtils.createReader(exptPath); BufferedReader br = new BufferedReader(r)) {
        exptMap = ExperimentUtils.createFilenameToIdMap(br);
    } catch (IOException e) {
        logger.error("Caught an IOException when creating expt map.", e);
        System.exit(1);
    }

    // Start a timer.
    logger.info("Gigaword -> Concrete beginning.");
    StopWatch sw = new StopWatch();
    sw.start();
    // Iterate over expt map.
    exptMap.entrySet()
            // .parallelStream()
            .forEach(p -> {
                final String pathStr = p.getKey();
                final Set<String> ids = p.getValue();
                final Path lp = Paths.get(pathStr);
                logger.info("Converting path: {}", pathStr);

                // Get the file name and immediate folder it is under.
                int nElements = lp.getNameCount();
                Path fileName = lp.getName(nElements - 1);
                Path subFolder = lp.getName(nElements - 2);
                String newFnStr = fileName.toString().split("\\.")[0] + ".tar";

                // Mirror folders in output dir.
                Path localOutFolder = outPath.resolve(subFolder);
                Path localOutPath = localOutFolder.resolve(newFnStr);

                // Create output subfolders.
                if (!Files.exists(localOutFolder) && !Files.isDirectory(localOutFolder)) {
                    logger.info("Creating out file: {}", localOutFolder.toString());
                    try {
                        Files.createDirectories(localOutFolder);
                    } catch (IOException e) {
                        throw new RuntimeException("Caught an IOException when creating output dir.", e);
                    }
                }

                // Iterate over communications.
                Iterator<Communication> citer;
                try (OutputStream os = Files.newOutputStream(localOutPath);
                        BufferedOutputStream bos = new BufferedOutputStream(os);
                        Archiver archiver = new TarArchiver(bos);) {
                    citer = new ConcreteGigawordDocumentFactory().iterator(lp);
                    while (citer.hasNext()) {
                        Communication c = citer.next();
                        String cId = c.getId();

                        // Document ID must be in the set. Remove.
                        boolean wasInSet = ids.remove(cId);
                        if (!wasInSet) {
                            // Some IDs are duplicated in Gigaword.
                            // See ERRATA.
                            logger.debug(
                                    "ID: {} was parsed from path: {}, but was not in the experiment map. Attempting to remove dupe.",
                                    cId, pathStr);

                            // Attempt to create a duplicate id (append .duplicate to the id).
                            // Then, try to remove again.
                            String newId = RepairDuplicateIDs.repairDuplicate(cId);
                            boolean dupeRemoved = ids.remove(newId);
                            // There are not nested duplicates, so this should never fire.
                            if (!dupeRemoved) {
                                logger.info("Failed to remove dupe.");
                                return;
                            } else
                                // Modify the communication ID to the unique version.
                                c.setId(newId);
                        }

                        archiver.addEntry(new ArchivableCommunication(c));
                    }

                    logger.info("Finished path: {}", pathStr);
                } catch (ConcreteException ex) {
                    logger.error("Caught ConcreteException during Concrete mapping.", ex);
                    logger.error("Path: {}", pathStr);
                } catch (IOException e) {
                    logger.error("Error archiving communications.", e);
                    logger.error("Path: {}", localOutPath.toString());
                }
            });

    sw.stop();
    logger.info("Finished.");
    Minutes m = new Duration(sw.getTime()).toStandardMinutes();
    logger.info("Runtime: Approximately {} minutes.", m.getMinutes());
}

From source file:de.kitsunealex.projectx.init.ModConfig.java

public static void loadConfig(File file) {
    Configuration config = new Configuration(file);
    StopWatch timer = new StopWatch();
    timer.start();//from   ww w. j a  va 2 s  .c o  m
    config.load();
    addProperties(config);
    config.save();
    timer.stop();
    ProjectX.LOGGER.info("Loaded config file in {}ms!", timer.getTime());
}

From source file:de.micromata.genome.logging.PerformanceCollector.java

/**
 * Adds the./* ww  w  .j ava 2s  . com*/
 *
 * @param ptype the ptype
 * @param watch the watch
 */
public static void add(PerformanceType ptype, StopWatch watch) {
    watch.stop();
    addIntern(ptype.name(), watch.getTime(), 0, ptype.getStatsCategory());
}