Example usage for org.springframework.util StopWatch start

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

Introduction

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

Prototype

public void start() throws IllegalStateException 

Source Link

Document

Start an unnamed task.

Usage

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

public static void main(String[] args) {
    StopWatch sw = new StopWatch("HelloServiceExporter");
    sw.start();
    new ClassPathXmlApplicationContext("hello-service-exporter.xml", SpringHelloServiceExporter.class);
    sw.stop();//w w w.  j  av  a  2 s.  com
    logger.info(sw.prettyPrint());
}

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

public static void main(String[] args) throws Exception {
    StopWatch sw = new StopWatch("HelloServiceExporter");
    sw.start();
    MinaServiceExporter exporter = new MinaServiceExporter();
    exporter.setIoAcceptor((IoAcceptor) new NioSocketAcceptorFactoryBean().getObject());
    exporter.setService(new DefaultHelloService());
    exporter.setServiceInterface(HelloService.class);
    exporter.afterPropertiesSet();//from  w w  w . j a  v a2 s  . c  om
    sw.stop();
    logger.info(sw.prettyPrint());
}

From source file:test.node.TestNodeWorker.java

public static void main(String[] args) {

    try {//from w w  w.ja  v a 2  s  . c  o  m

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        // Start Grid Node
        GridNode node = Grid.startGridNode();

        sw.stop();
        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        log.info("GridNode ID : " + node.getId());

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

        log.info("Unregistered, Terminating...");
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:kymr.github.io.future.LoadTest.java

public static void main(String[] args) throws InterruptedException {
    ExecutorService es = Executors.newFixedThreadPool(100);

    RestTemplate rt = new RestTemplate();
    String url = "http://localhost:8080/dr";

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

    for (int i = 0; i < 100; i++) {
        es.execute(() -> {/*from w  w  w.j  ava  2s .  com*/
            int idx = counter.addAndGet(1);
            log.info("Thread {}", idx);

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

            rt.getForObject(url, String.class);

            sw.stop();
            log.info("Elapsed: {} -> {}", idx, sw.getTotalTimeSeconds());
        });
    }

    es.shutdown();
    es.awaitTermination(100, TimeUnit.SECONDS);

    main.stop();
    log.info("Total: {}", main.getTotalTimeSeconds());
}

From source file:test.node.TestUnboudedJobRunner.java

public static void main(String[] args) {
    // Test Job/*from  w  w  w .j  av a  2  s . c  o  m*/
    TestUnboundedJob testJob = new TestUnboundedJob();

    try {

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        GridNode node = Grid.startGridNode();

        log.info("GridNode ID : " + node.getId());

        sw.stop();

        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        // Submit Job
        log.debug("Submitting Job");

        sw.start();

        GridJobFuture future = node.getJobSubmissionService().submitJob(testJob, new ResultCallback() {

            public void onResult(Serializable result) {
                System.err.println(result);
            }

        });

        while (!future.isJobFinished()) {
            Thread.sleep(1000);
        }

        sw.stop();
        log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms");

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

        log.info("Unregistered, Terminating...");
        System.exit(0);

    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:test.node.TestNodeNARRunner.java

public static void main(String[] args) {
    try {//www  .  java2 s .  co  m

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        GridNode node = Grid.startGridNode();

        log.info("GridNode ID : " + node.getId());

        sw.stop();

        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        // Submit Job
        log.debug("Reading NAR");

        sw.start();

        GridArchive archive;
        archive = GridArchive.fromFile(new File("simpletestjob.nar"));

        log.debug("Submitting NAR");

        GridJobFuture future = (GridJobFuture) node.getJobSubmissionService().submitArchive(archive).values()
                .toArray()[0];

        try {
            log.info("RESULT : " + future.getResult());
        } catch (RemoteInvocationFailureException e) {
            e.getCause().printStackTrace();
        }

        sw.stop();
        log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms");

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

        log.info("Unregistered, Terminating...");
        System.exit(0);

    } catch (GridArchiveException e) {
        log.fatal("GridArchiveException", e);
    } catch (GridExecutionException e) {
        log.fatal("Execution Failed", e);
    } catch (IOException e) {
        log.error("IOException", e);
    }

}

From source file:test.node.TestNodeRunner.java

public static void main(String[] args) {

    // Test Job/* www .j a  va  2 s.c  o m*/
    TestJob testJob = new TestJob();

    try {

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        GridNode node = Grid.startGridNode();

        log.info("GridNode ID : " + node.getId());

        sw.stop();

        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        // Submit Job
        log.debug("Submitting Job");

        sw.start();

        GridJobFuture future = node.getJobSubmissionService().submitJob(testJob, new ResultCallback() {

            public void onResult(Serializable result) {
                System.err.println(result);
            }

        });
        try {
            log.info("Job Result : " + future.getResult());
        } catch (RemoteInvocationFailureException e) {
            e.getCause().printStackTrace();
        }

        sw.stop();
        log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms");

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

        log.info("Unregistered, Terminating...");
        System.exit(0);

    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:test.buddhabrot.BuddhabrotApp.java

public static void main(String[] args) {

    log.info("GridNode Starting...");
    StopWatch sw = new StopWatch();
    sw.start();

    GridNode node = Grid.startLightGridNode();

    log.info("GridNode ID : " + node.getId());

    log.info("Registered in Cluster : " + node.getNodeRegistrationService().getRegistration().getClusterId());

    sw.stop();// w  ww .  j av  a2s.  co m

    log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

    // Create App Instance
    final BuddhabrotApp app = new BuddhabrotApp(node);

    app.requestFocus();

    // Create Buddhabrot Job
    BuddhabrotJob buddhabrotJob = new BuddhabrotJob(WIDTH, HEIGHT);

    // Start Job Submission
    sw.start();

    System.err.println(new Date());

    GridJobFuture future = node.getJobSubmissionService().submitJob(buddhabrotJob, new ResultCallback() {

        public void onResult(Serializable result) {

            log.debug("CALLBACK");

            if (result == null)
                return;
            if (result instanceof int[][]) {
                app.onResult((int[][]) result);
            }
        }

    });

    app.setFuture(future);

}

From source file:test.mandelbrot.MandelbrotApp.java

public static void main(String[] args) {

    try {/*from   ww  w . j  a  v  a  2 s . c  o m*/

        log.info("GridNode Starting...");
        StopWatch sw = new StopWatch();
        sw.start();

        GridNode node = Grid.startLightGridNode();

        log.info("GridNode ID : " + node.getId());

        sw.stop();

        log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]");

        // Create App Instance
        final MandelbrotApp app = new MandelbrotApp(node);

        app.requestFocus();

        // Create Mandelbrot Job
        MandelbrotJob mandelbrotJob = new MandelbrotJob(app.getWidth(), app.getHeight());

        // Start Job Submission
        sw.start();

        GridJobFuture future = node.getJobSubmissionService().submitJob(mandelbrotJob, new ResultCallback() {

            public void onResult(Serializable result) {

                MandelbrotResult mResult = (MandelbrotResult) result;
                app.displayResult(mResult);
                app.setProgress(app.getProgress() + mResult.getLines());
            }

        });

        app.setFuture(future);
        // Block till job finishes
        future.getResult();
        app.setDone(true);

        sw.stop();

        log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms");

        log.debug("Press any key to unregister GridNode and terminate");
        System.in.read();
        node.getNodeRegistrationService().unregister();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:test.mandelbrot.SequentialMandelbrotApp.java

public static void main(String[] args) {

    log.info("Starting Sequential Mandelbrot Application");
    // Create App Instance
    SequentialMandelbrotApp app = new SequentialMandelbrotApp();

    app.requestFocus();/*  w  ww .  j a v  a 2 s  . c o m*/

    StopWatch sw = new StopWatch();
    log.info("Starting Computation...");
    sw.start();

    // Start Rendering
    app.startRendering();

    sw.stop();

    log.info("Computation Complete... " + sw.getLastTaskTimeMillis() + "ms");
    //System.exit(0);

}