List of usage examples for org.springframework.util StopWatch stop
public void stop() throws IllegalStateException
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();//from w w w . jav a 2s .c o m for (int i = 0; i < 100; i++) { es.execute(() -> { 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.TestNodeWorker.java
public static void main(String[] args) { try {/* w w w . j a va 2 s . co 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:com.javacreed.examples.cache.part2.FictitiousLongRunningTask.java
public static void main(final String[] args) throws Exception { final FictitiousLongRunningTask task = new FictitiousLongRunningTask(); final StopWatch stopWatch = new StopWatch("Fictitious Long Running Task"); stopWatch.start("First Run"); task.computeLongTask("a"); stopWatch.stop(); stopWatch.start("Other Runs"); for (int i = 0; i < 100; i++) { task.computeLongTask("a"); }/* www.j a va2 s.c om*/ stopWatch.stop(); FictitiousLongRunningTask.LOGGER.debug("{}", stopWatch); }
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();/* w w w. ja v a 2 s . com*/ new ClassPathXmlApplicationContext("hello-service-exporter.xml", SpringHelloServiceExporter.class); sw.stop(); logger.info(sw.prettyPrint()); }
From source file:test.node.TestUnboudedJobRunner.java
public static void main(String[] args) { // Test Job/*from ww w . ja v 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 {/*from ww w . j a v a 2 s. c om*/ 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/* w ww. j av a2 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.mandelbrot.SequentialMandelbrotApp.java
public static void main(String[] args) { log.info("Starting Sequential Mandelbrot Application"); // Create App Instance SequentialMandelbrotApp app = new SequentialMandelbrotApp(); app.requestFocus();/*from w w w .ja v a2s .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); }
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();//from www .ja v a 2 s . c o m MinaServiceExporter exporter = new MinaServiceExporter(); exporter.setIoAcceptor((IoAcceptor) new NioSocketAcceptorFactoryBean().getObject()); exporter.setService(new DefaultHelloService()); exporter.setServiceInterface(HelloService.class); exporter.afterPropertiesSet(); sw.stop(); logger.info(sw.prettyPrint()); }
From source file:test.mandelbrot.MandelbrotApp.java
public static void main(String[] args) { try {/*from w w w .j a va2s. co 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(); } }