List of usage examples for org.springframework.util StopWatch prettyPrint
public String prettyPrint()
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();/* ww w . java 2s .com*/ new ClassPathXmlApplicationContext("hello-service-exporter.xml", SpringHelloServiceExporter.class); sw.stop(); 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();/*from w w w . java 2 s . c om*/ 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:edu.isistan.carcha.CarchaPipeline.java
/** * The main method.//from www . j a v a 2 s . co m * * @param args the arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { String inputDirectory = args[0]; String output = args[1]; CarchaPipeline carcha = new CarchaPipeline(); StopWatch sw = new StopWatch(); sw.start("executeStanfordAnnotators"); if (args.length > 2 && args[2].equals("write")) { logger.info("Write Design Decision to file"); carcha.writeAnnotations(inputDirectory, output); } else if (args.length > 2 && args[2].equals("sentence")) carcha.writeSentences(inputDirectory, output); else if (args.length > 2 && args[2].equals("sentence-annotator")) carcha.executeSentenceAnnotator(inputDirectory, output); else carcha.executeUIMAAnnotator(inputDirectory, output); sw.stop(); logger.info(sw.prettyPrint()); }
From source file:gda.device.detector.mythen.data.DataLoadAlgorithmExperiment.java
public static void main(String args[]) throws Exception { final File dataFile = TestUtils.getResourceAsFile(DataLoadAlgorithmExperiment.class, TEST_FILE); final String filename = dataFile.getAbsolutePath(); StopWatch sw = new StopWatch(DataLoadAlgorithmExperiment.class.getSimpleName()); Algorithm loadUsingCurrentAlgorithm = new Algorithm("loadUsingCurrentAlgorithm") { @Override/*from w w w. j a v a2 s . c om*/ public void run() throws Exception { MythenDataFileUtils.readMythenProcessedDataFile(filename, false); } }; Algorithm loadByUsingSplit = new Algorithm("loadByUsingSplit") { @Override public void run() throws Exception { MythenDataFileUtils.loadByUsingSplit(filename); } }; Algorithm loadByUsingStreamTokenizer = new Algorithm("loadByUsingStreamTokenizer") { @Override public void run() throws Exception { MythenDataFileUtils.loadByUsingStreamTokenizer(filename, FileType.PROCESSED); } }; Algorithm loadByReadingFileContentAndUsingSplit = new Algorithm("loadByReadingFileContentAndUsingSplit") { @Override public void run() throws Exception { MythenDataFileUtils.loadByReadingFileContentAndUsingSplit(filename); } }; Algorithm loadByReadingFileContentAndUsingStreamTokenizer = new Algorithm( "loadByReadingFileContentAndUsingStreamTokenizer") { @Override public void run() throws Exception { MythenDataFileUtils.loadByReadingFileContentAndUsingStreamTokenizer(filename, FileType.PROCESSED); } }; Algorithm[] algorithms = new Algorithm[] { loadUsingCurrentAlgorithm, loadByUsingSplit, loadByUsingStreamTokenizer, loadByReadingFileContentAndUsingSplit, loadByReadingFileContentAndUsingStreamTokenizer }; for (Algorithm a : algorithms) { System.out.printf("Testing '%s' algorithm...\n", a.name); // warm-up for (int i = 0; i < 1000; i++) { a.run(); } // timing sw.start(a.name); for (int i = 0; i < 1000; i++) { a.run(); } sw.stop(); } // display results System.out.println(sw.prettyPrint()); }
From source file:com.project.atm.core.App.java
static void loadDistanceMatrix() throws FileNotFoundException { //change the path file to correct location ! scDistance = new Scanner(new FileReader("/home/andry/Documents/atm/atmDistance.txt")); // load data from file int i = 1;/*from www.j a v a 2 s .com*/ int j = 1; int total = locationList.size(); distance = new double[total][total]; logger.info("loading distance matrix tab file................."); StopWatch stopWatch = new StopWatch("Travel distance calculation"); stopWatch.start("load distance matrix file"); // convert matrix data to array while (scDistance.hasNextLine()) { //logger.info("i => "+ i +", j => "+j); distance[i - 1][j - 1] = scDistance.nextDouble(); if ((j % total) == 0) { i++; j = 0; if (i == total + 1) break; } j++; } stopWatch.stop(); logger.info(stopWatch.prettyPrint()); logger.info(stopWatch.prettyPrint()); }
From source file:com.project.atm.core.App.java
private static void generateGraphData() { StopWatch stopWatch = new StopWatch("Generate Graph from data"); stopWatch.start("run the shortest path algorithm"); // generate graph graph = new SimpleWeightedGraph<String, DefaultWeightedEdge>(DefaultWeightedEdge.class); // create vertex for (int c = 0; c < distance.length; c++) { graph.addVertex(getLocationById(c).getName()); }/*ww w . j a v a 2 s . c o m*/ // set weight for (int x = 0; x < distance.length; x++) { for (int y = 0; y < distance.length; y++) { if (x != y) { if (getLocationById(x) != null && getLocationById(y) != null) { DefaultWeightedEdge e = graph.addEdge(getLocationById(x).getName(), getLocationById(y).getName()); if (e != null) graph.setEdgeWeight(e, distance[x][y]); } } } } stopWatch.stop(); logger.info(stopWatch.prettyPrint()); }
From source file:com.cedarsoft.history.core.GlazedPerformanceTest.java
@Test public void testTiming() { for (int i = 0; i < 5; i++) { checkPerformance(new ArrayList<String>()); checkPerformance(GlazedLists.<String>eventList(new ArrayList<String>())); }//from ww w . j a va 2 s . c o m StopWatch watch0 = checkPerformance(new ArrayList<String>()); System.out.println(watch0.prettyPrint()); StopWatch watch1 = checkPerformance(GlazedLists.<String>eventList(new ArrayList<String>())); System.out.println(watch1.prettyPrint()); System.out.println("Delta: " + (watch1.getTotalTimeMillis() - watch0.getTotalTimeMillis())); }
From source file:rk.java.compute.cep.EventBusTest.java
@Test public void processOnThreadPerSymbolBasis() throws Exception { ComputeService dispatcher = new ComputeService(numberOfMarketSourceInstances, priceEventSink); dispatcher.subscribeToTickEventsFrom(eventBus); for (int i = 0; i < numberOfMarketSourceInstances; i++) { TradeFeed market = new TradeFeed(numberOfTicksPerProducer); market.setName("Market Maker " + i); market.publishTickEventsTo(eventBus); market.setDaemon(true);//www. j a v a2s. c o m market.start(); } StopWatch await = dispatcher.shutDownAndAwaitTermination(1, TimeUnit.MINUTES); System.out.println(await.prettyPrint()); System.out.println(dispatcher); /* * Rem to add for poison pills when counting... */ assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksReceivedCount()); assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksProcessedCount()); }
From source file:rk.java.compute.cep.EventBusTest.java
@Test public void processOnThreadPerCoreBasis() throws Exception { int NUMBER_OF_CORES = 8; ComputeService dispatcher = new ComputeService(numberOfMarketSourceInstances, NUMBER_OF_CORES, priceEventSink);// ww w . j a va 2 s .c o m dispatcher.subscribeToTickEventsFrom(eventBus); for (int i = 0; i < numberOfMarketSourceInstances; i++) { TradeFeed market = new TradeFeed(numberOfTicksPerProducer); market.setName("Market Maker " + i); market.setDaemon(true); market.publishTickEventsTo(eventBus); market.start(); } StopWatch await = dispatcher.shutDownAndAwaitTermination(1, TimeUnit.MINUTES); System.out.println(await.prettyPrint()); System.out.println(dispatcher); /* * Rem to add for poison pills when counting... */ assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksReceivedCount()); assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksProcessedCount()); }
From source file:org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice.java
@Around("aspectjLoadTimeWeavingExamples()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { final Logger logger = LoggerFactory.getLogger(pjp.getSignature().getDeclaringType()); StopWatch sw = new StopWatch(getClass().getSimpleName()); try {// w w w . j av a 2 s. co m sw.start(pjp.getSignature().getName()); return pjp.proceed(); } finally { sw.stop(); logger.debug(sw.prettyPrint()); } }