List of usage examples for org.springframework.util StopWatch start
public void start(String taskName) throws IllegalStateException
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();//from w ww .ja v a2s . c o m stopWatch.start("Other Runs"); for (int i = 0; i < 100; i++) { task.computeLongTask("a"); } stopWatch.stop(); FictitiousLongRunningTask.LOGGER.debug("{}", stopWatch); }
From source file:edu.isistan.carcha.CarchaPipeline.java
/** * The main method./*w w w . jav a2s . c o 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/*ww w . j a va2 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.home.ln_spring.ch4.mi.MethodReplacementExample.java
private static void displayInfo(ReplacementTarget target) { System.out.println(target.formatMessage("Hello World!")); StopWatch stopWatch = new StopWatch(); stopWatch.start("perfTest"); for (int x = 0; x < 1000000; x++) { String out = target.formatMessage("foo"); }/*from www .j a v a2 s.c o m*/ stopWatch.stop(); System.out.println("1000000 invocations took: " + stopWatch.getTotalTimeMillis() + " ms."); }
From source file:com.home.ln_spring.ch4.mi.lookupDemo.java
public static void displayInfo(DemoBean bean) { MyHelper helper1 = bean.getMyHelper(); MyHelper helper2 = bean.getMyHelper(); System.out.println("Helper Instances the Same?: " + (helper1 == helper2)); StopWatch stopWatch = new StopWatch(); stopWatch.start("lookupDemo"); for (int x = 0; x < 100000; x++) { MyHelper helper = bean.getMyHelper(); helper.doSomethingHelpful();/*w w w .j a va 2 s . co m*/ } stopWatch.stop(); System.out.println("100000 gets took " + stopWatch.getTotalTimeMillis() + " ms"); }
From source file:com.cedarsoft.history.core.GlazedPerformanceTest.java
private static StopWatch checkPerformance(@Nonnull List<String> list) { StopWatch stopWatch = new StopWatch(); stopWatch.start("adding to " + list.getClass().getName()); for (int i = 0; i < 100000; i++) { list.add(String.valueOf(i)); }//w w w. jav a 2s . co m stopWatch.stop(); stopWatch.start("iterating through " + list.getClass().getName()); for (String currentEntry : list) { assertNotNull(currentEntry); } stopWatch.stop(); assertNotNull(stopWatch); return stopWatch; }
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()); }/*from ww w.j a va 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.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 w w w .j a va 2 s . co m 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:profiling.ProfilingInterceptor.java
@Override public Object invoke(MethodInvocation mi) throws Throwable { StopWatch sw = new StopWatch(); sw.start(mi.getMethod().getName()); String methodName = mi.getMethod().getName(); if ("sayNigga".equals(methodName)) { System.out.println("FUCK YOU NIGGA!"); return null; }/*from w w w .j a v a2 s . c o m*/ Object returnValue = mi.proceed(); sw.stop(); dumpInfo(mi, sw.getTotalTimeMillis()); return returnValue; }
From source file:net.sf.gazpachoquest.aspects.ProfilingAdvise.java
public Object doProfiling(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { String taskName = createTaskName(proceedingJoinPoint); StopWatch taskTimer = new StopWatch(); try {/*from w w w . j a v a2 s . co m*/ taskTimer.start(taskName); return proceedingJoinPoint.proceed(); } finally { taskTimer.stop(); doLogging(taskTimer.getLastTaskInfo()); } }