Example usage for com.google.common.base Stopwatch createStarted

List of usage examples for com.google.common.base Stopwatch createStarted

Introduction

In this page you can find the example usage for com.google.common.base Stopwatch createStarted.

Prototype

@CheckReturnValue
public static Stopwatch createStarted() 

Source Link

Document

Creates (and starts) a new stopwatch using System#nanoTime as its time source.

Usage

From source file:org.anarres.dblx.core.Main.java

public static void main(String[] args) throws Exception {
    Stopwatch stopwatch = Stopwatch.createStarted();
    Arguments arguments = new Arguments(args);
    GenericApplicationContext context = new GenericApplicationContext();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(context);
    reader.register(AppConfiguration.class);
    for (AppConfiguration.Provider configurationProvider : ServiceLoader
            .load(AppConfiguration.Provider.class)) {
        for (Class<?> configurationClass : configurationProvider.getConfigurationClasses()) {
            LOG.debug("Registering additional ServerConfiguration class " + configurationClass.getName());
            reader.register(configurationClass);
        }//from ww w  . ja v  a  2  s  .c  om
    }
    SpringUtils.addConfigurations(context, arguments);
    context.refresh();
    context.registerShutdownHook();
    context.start();

    LOG.info("Ready; startup took " + stopwatch);
}

From source file:end2end.Profiling.java

public static void main(String[] args) {
    try {//from  w w w . j a  va  2s  .  co  m
        String line = "------------------------------";
        System.out.println(line);
        System.out.println("EvoRS console");
        System.out.println(line);

        final Stopwatch stopwatch = Stopwatch.createStarted();

        System.out.println("Starting...");

        RobotExperiment exp;
        exp = RobotExperiment.fromDirectory(System.getProperty("user.dir") + "/demo/"); //load the demo layout and world

        final RobotGARunner gaRunner = new RobotGARunner(new RobotPhenotype(exp), true);

        System.out.println("");
        System.out.printf("Initialised in %d milliseconds\n", stopwatch.elapsed(TimeUnit.MILLISECONDS));

        System.out.println(line);
        System.out.println("");

        System.out.println(gaRunner.getProgressReportHeader());

        gaRunner.setListener(new RobotGARunner.GAListener() {
            long lastGenTime = -1;

            @Override
            public void doUpdate() {
                if (lastGenTime != -1)
                    System.out.printf("Generation done in %d milliseconds\n",
                            stopwatch.elapsed(TimeUnit.MILLISECONDS) - lastGenTime);
                lastGenTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
                System.out.println(gaRunner.getProgressReportLine());

            }

            @Override
            public void finished() {
                System.out.printf("Finished in %d milliseconds\n", stopwatch.elapsed(TimeUnit.MILLISECONDS));
            }
        });

        new Thread(gaRunner).start();

    } catch (IOException ex) {
        Logger.getLogger(Profiling.class.getName()).log(Level.SEVERE, null, ex);
        System.exit(1);
    }
}

From source file:ch.petikoch.examples.rxjava.backup_requests.WordCountWithBackupRequests.java

public static void main(String[] args) throws InterruptedException {

    int numberOfSentences = 5_000;

    System.out.println("-----------------------------------------------------------------------");
    Stopwatch stopwatch = Stopwatch.createStarted();
    Observable.just(THE_SENTENCE).repeat(numberOfSentences).toBlocking().forEach(theSentence -> sysout(
            "Result arrived: " + theSentence + " -> " + fastWordCount(theSentence) + " words"));
    System.out.println("Elapsed: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
    System.out.println("Fast... just as warm-up.");

    System.out.println("-----------------------------------------------------------------------");
    stopwatch = Stopwatch.createStarted();
    Observable.just(THE_SENTENCE).repeat(numberOfSentences).toBlocking().forEach(theSentence -> sysout(
            "Result arrived: " + theSentence + " -> " + fastWordCount(theSentence) + " words"));
    System.out.println("Elapsed: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
    System.out.println("Fast, again. After warm-up our 'reference'.");

    /*/*from   w ww.j ava2 s  .  c  o m*/
    System.out.println("-----------------------------------------------------------------------");
    Thread.sleep(5000);
    stopwatch = Stopwatch.createStarted();
    Observable.just(THE_SENTENCE).repeat(numberOfSentences)
        .toBlocking()
        .forEach(theSentence -> sysout("Result arrived: " + theSentence + " -> " + wordCountWithCachedThread(theSentence)
                .toBlocking()
                .first()
                + " words"));
    System.out.println("Elapsed: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
    System.out.println("Fast 2... Same as first, but executed on separate, cached thread. Just to see the overhead.");
    */

    System.out.println("-----------------------------------------------------------------------");
    Thread.sleep(5000);
    stopwatch = Stopwatch.createStarted();
    Observable.just(THE_SENTENCE).repeat(numberOfSentences).toBlocking().forEach(theSentence -> sysout(
            "Result arrived: " + theSentence + " -> " + sometimesSlowWordCount(theSentence) + " words"));
    System.out.println("Elapsed: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
    System.out.println("Sometimes slow... Now we have sometimes some latency. How to deal with this?");

    System.out.println("-----------------------------------------------------------------------");
    Thread.sleep(5000);
    stopwatch = Stopwatch.createStarted();
    Observable.just(THE_SENTENCE).repeat(numberOfSentences).toBlocking()
            .forEach(theSentence -> sysout("Result arrived: " + theSentence + " -> "
                    + sometimesSlowWordCountWithBackupRequests(theSentence) + " words"));
    System.out.println("Elapsed: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
    System.out.println(
            "Sometimes slow with backup requests... pretty fast, again. Backup requests work! Whew... ");
}

From source file:org.glowroot.local.store.TraceDaoPerformanceMain.java

public static void main(String... args) throws Exception {
    DataSource dataSource = new DataSource();
    CappedDatabase cappedDatabase = new CappedDatabase(new File("glowroot.capped.db"), 1000000);
    TraceDao traceDao = new TraceDao(dataSource, cappedDatabase);

    Stopwatch stopwatch = Stopwatch.createStarted();
    for (int i = 0; i < 1000; i++) {
        Trace trace = TraceTestData.createTrace();
        CharSource entries = TraceTestData.createEntries();
        traceDao.store(trace, entries, null);
    }// www . j  a  v  a 2  s  .  c  o  m
    logger.info("elapsed time: {}", stopwatch.elapsed(MILLISECONDS));
    logger.info("num traces: {}", traceDao.count());
}

From source file:com.jejking.hh.nord.gazetteer.osm.streets.MapStreetsToPolygons.java

/**
 * Maps the extracted streets to the lowest level administrative districts, the "Ortsteile", numbered districted.
 * /*from  w  w  w .j a  v a2  s  .co  m*/
 * @param args
 *            directory in which the Neo4j database exists.
 */
public static void main(String[] args) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]);
    registerShutdownHook(graph);

    MapStreetsToPolygons.mapStreetsToAdminPolygons(graph);
    System.out.println(
            "Linked streets to polygons. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");

}

From source file:nl.knaw.huygens.timbuctoo.tools.other.EnvironmentCleaner.java

public static void main(String[] args) throws Exception {
    Stopwatch stopWatch = Stopwatch.createStarted();

    Configuration config = new Configuration("config.xml");

    new EnvironmentCleaner().clean(config, Guice.createInjector(new ToolsInjectionModule(config, true, true)));

    LOG.info("Time used: {}", stopWatch);
}

From source file:de.unentscheidbar.csv2.ProfileMe.java

public static void main(String[] args) throws Exception {

    File gofile = new File("go");
    while (!gofile.exists()) {
        System.out.println("Waiting...");
        Thread.sleep(1000);/*ww w .ja  v  a2 s  . c om*/
    }
    double kibPerRun = csv.length() / 2048.0;
    System.out.println("go " + kibPerRun + " kib");
    while (gofile.exists()) {
        Stopwatch sw = Stopwatch.createStarted();
        long ops = operation();
        long micros = sw.elapsed(TimeUnit.MICROSECONDS);
        System.out.println("@" + ((ops * kibPerRun / micros) * 1_000_000 / 1024.0) + " mbps");
    }
    System.out.println("exiting");
}

From source file:org.hyperledger.perftest.PerfTestApp.java

public static void main(String[] args) throws Exception {
    Stopwatch watch = Stopwatch.createStarted();
    System.setProperty("logback.configurationFile", "logback.xml");
    int rounds = Integer.parseInt(args[2]);
    int count = Integer.parseInt(args[3]);
    //        int threadCount = Integer.parseInt(args[4]);
    int threadCount = 1;
    PerfTestApp app = new PerfTestApp(rounds, count, threadCount);
    app.measure(app.bcsapi);//from  w  w w .j av a2 s  .  c om
    app.stop();
    watch.stop();
    System.out.println("DONE in " + watch.elapsed(TimeUnit.SECONDS) + " seconds");
    System.exit(0);
}

From source file:com.jejking.hh.nord.gazetteer.opendata.CreatePartialGazetteerWithOpenData.java

/**
 * Main method.//from w  w  w . j  a  va2 s.co m
 * 
 * @param args
 *            , first arg is path to directory in which to create/open a Neo4j database with the gazetteer.
 */
public static void main(String[] args) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]);
    registerShutdownHook(graph);

    // we want an additional index on adminstrative area - name
    setupSchema(graph);
    System.out.println("Setup indexes. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");

    CreatePartialGazetteerWithOpenData.writeHamburgPolygons(graph);
    System.out.println(
            "Wrote hamburg polygons. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");
}

From source file:com.jejking.hh.nord.gazetteer.osm.poi.WritePointsOfInterest.java

/**
 * @param args/*from w w  w. j a v  a2 s.com*/
 */
public static void main(String[] args) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
    GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]);
    registerShutdownHook(graph);

    WritePointsOfInterest.writePointsOfInterest(geometryFactory, graph);
    System.out.println(
            "Wrote points of interest. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds");
}