List of usage examples for org.apache.commons.lang.time StopWatch StopWatch
public StopWatch()
Constructor.
From source file:MainClass.java
public static void main(String[] args) { StopWatch stWatch = new StopWatch(); //Start StopWatch stWatch.start();//from ww w .ja v a 2 s .c o m //Get iterator for all days in a week starting Monday Iterator itr = DateUtils.iterator(new Date(), DateUtils.RANGE_WEEK_MONDAY); while (itr.hasNext()) { Calendar gCal = (Calendar) itr.next(); System.out.println(gCal.getTime()); } //Stop StopWatch stWatch.stop(); System.out.println("Time Taken >>" + stWatch.getTime()); }
From source file:TimeTrial.java
public static void main(String[] args) { StopWatch stWatch = new StopWatch(); // Start StopWatch stWatch.start();/* ww w .j a v a 2s . c o m*/ // Get iterator for all days in a week starting Monday Iterator itr = DateUtils.iterator(new Date(), DateUtils.RANGE_WEEK_MONDAY); while (itr.hasNext()) { Calendar gCal = (Calendar) itr.next(); System.out.println(gCal.getTime()); } // Stop StopWatch stWatch.stop(); System.out.println("Time Taken >>" + stWatch.getTime()); }
From source file:hadoop.Main.java
public static void main(String[] args) throws Exception { StopWatch timer = new StopWatch(); timer.start();/*from www . java 2 s .co m*/ System.out.println("Main program is starting"); String dir = "hdfs://127.0.1.1:9000/user/fiqie/twitter/"; Configuration conf = new Configuration(); conf.set("fs.default.name", "hdfs://127.0.1.1:9000"); FileSystem fs = FileSystem.get(conf); String[] prepareOpts = { dir + "input/small.txt", dir + "output/pr-0.out" }; ToolRunner.run(new Configuration(), new InitPageRank(), prepareOpts); //String[] initOpts = { dir + "output/prepared.out", dir + "output/pr-0.out" }; //ToolRunner.run(new Configuration(), new InitPageRankDriver(), initOpts); for (int i = 1; i <= NUMBER_OF_ITERATION; i++) { String previous = dir + "output/pr-" + (i - 1) + ".out"; String current = dir + "output/pr-" + i + ".out"; String[] opts = { previous, current }; ToolRunner.run(new Configuration(), new CalculatePageRank(), opts); if (i == NUMBER_OF_ITERATION) { String[] finalOpts = { dir + "output/pr-" + i + ".out", dir + "output/pr-final.out" }; ToolRunner.run(new Configuration(), new FinishPageRank(), finalOpts); } } timer.stop(); System.out.println("Elapsed " + timer.toString()); }
From source file:MainClass.java
public static void main(String[] args) { StopWatch clock = new StopWatch(); NumberFormat format = NumberFormat.getInstance(); System.out.println("How long does it take to take the sin of 0.34 ten million times?"); clock.start();//from www .ja va 2 s . c o m for (int i = 0; i < 100000000; i++) { Math.sin(0.34); } clock.stop(); System.out.println("It takes " + clock.getTime() + " milliseconds"); System.out.println("How long does it take to multiply 2 doubles one billion times?"); clock.reset(); clock.start(); for (int i = 0; i < 1000000000; i++) { double result = 3423.2234 * 23e-4; } clock.stop(); System.out.println("It takes " + clock.getTime() + " milliseconds."); System.out.println("How long does it take to add 2 ints one billion times?"); clock.reset(); clock.start(); for (int i = 0; i < 1000000000; i++) { int result = 293842923 + 33382922; } clock.stop(); System.out.println("It takes " + clock.getTime() + " milliseconds."); System.out.println("Testing the split() method."); clock.reset(); clock.start(); try { Thread.sleep(1000); } catch (Exception e) { } clock.split(); System.out.println("Split Time after 1 sec: " + clock.getTime()); try { Thread.sleep(1000); } catch (Exception e) { } System.out.println("Split Time after 2 sec: " + clock.getTime()); clock.unsplit(); try { Thread.sleep(1000); } catch (Exception e) { } System.out.println("Time after 3 sec: " + clock.getTime()); }
From source file:de.unisb.cs.st.javalanche.mutation.util.FilePerformanceTest.java
public static void main(String[] args) throws IOException { int limit = 1000; int total = 0; StopWatch stp = new StopWatch(); stp.start();//from www. j av a 2s . c o m File dir = new File("mutation-files/tmp"); dir.mkdir(); for (int i = 0; i < limit; i++) { Map<String, Set<Integer>> map = getMap(); File tempFile = new File(dir, "test-" + i + ".ser"); if (!tempFile.exists()) { SerializeIo.serializeToFile(map, tempFile); } else { Map<String, Set<Integer>> deserialize = SerializeIo.get(tempFile); total += deserialize.size(); } } System.out.println( "Handling " + limit + " files took " + DurationFormatUtils.formatDurationHMS(stp.getTime())); }
From source file:elaborate.editor.backend.AnnotationMarkerScrubber.java
@SuppressWarnings("boxing") public static void main(String[] args) { StopWatch sw = new StopWatch(); sw.start();//from w w w . jav a 2s.c om EntityManager entityManager = HibernateUtil.beginTransaction(); TranscriptionService ts = TranscriptionService.instance(); ts.setEntityManager(entityManager); try { List<Transcription> resultList = entityManager// . .createQuery("select t from Transcription t", Transcription.class)// .getResultList(); int size = resultList.size(); int n = 1; for (Transcription t : resultList) { Log.info("indexing transcription {} ({}/{} = {}%)", new Object[] { t.getId(), n, size, percentage(n, size) }); String bodyBefore = t.getBody(); ts.cleanupAnnotations(t); String bodyAfter = t.getBody(); if (!bodyAfter.equals(bodyBefore)) { ProjectEntry projectEntry = t.getProjectEntry(); String projectname = projectEntry.getProject().getName(); long entryId = projectEntry.getId(); Log.info("url: http://test.elaborate.huygens.knaw.nl/projects/{}/entries/{}/transcriptions/{}", projectname, entryId, t.getTextLayer()); Log.info("body changed:\nbefore: {}\nafter:{}", bodyBefore, bodyAfter); } n++; } } finally { HibernateUtil.commitTransaction(entityManager); } sw.stop(); Log.info("done in {}", convert(sw.getTime())); }
From source file:de.tudarmstadt.ukp.dkpro.core.frequency.util.ProviderBenchmark.java
public static void main(String[] args) throws Exception { Web1TProviderBase web1t = new Web1TFileAccessProvider(args); Corpus brown = new BrownTeiCorpus(); StopWatch watch = new StopWatch(); watch.start();//w ww .j a v a 2 s. c o m watch.suspend(); for (Text text : brown.getTexts()) { for (Sentence s : text.getSentences()) { for (String t : s.getTokens()) { watch.resume(); web1t.getFrequency(t); watch.suspend(); } } } double time = (double) watch.getTime() / 1000; System.out.println(time + "s"); }
From source file:elaborate.editor.backend.Indexer.java
@SuppressWarnings("boxing") public static void main(String[] args) { boolean wipeIndexFirst = args.length == 0 ? false : "-w".equals(args[0]); StopWatch sw = new StopWatch(); sw.start();/*from ww w. jav a 2s .com*/ ElaborateSolrIndexer solr = new ElaborateSolrIndexer(); if (wipeIndexFirst) { Log.info("clearing index"); solr.clear(); } EntityManager entityManager = HibernateUtil.getEntityManager(); try { ProjectEntryService projectEntryService = ProjectEntryService.instance(); projectEntryService.setEntityManager(entityManager); List<ProjectEntry> projectentries = projectEntryService.getAll(); int size = projectentries.size(); Log.info("indexing {} projectEntries", size); int n = 1; for (ProjectEntry projectEntry : projectentries) { Log.info("indexing projectEntry {} ({}/{} = {}%) (est. time remaining: {})", // new Object[] { // projectEntry.getId(), n, size, // percentage(n, size), // time_remaining(n, size, sw.getTime()) // } // ); solr.index(projectEntry, autoCommit(n)); n++; } } finally { entityManager.close(); } solr.commit(); sw.stop(); Log.info("done in {}", convert(sw.getTime())); }
From source file:com.eaio.uuid.UUIDPerformance.java
public static void main(String[] args) { Thread[] threads = new Thread[Runtime.getRuntime().availableProcessors()]; for (int i = 0; i < threads.length; ++i) { threads[i] = new Thread(new UUIDRunnable(count / threads.length)); }//from w ww .java 2s.c o m StopWatch watch = new StopWatch(); watch.start(); for (Thread t : threads) { t.start(); } for (Thread t : threads) { try { t.join(); } catch (InterruptedException e) { // Moo } } watch.stop(); System.out.println(watch.getTime()); }
From source file:com.liferay.portal.tools.DBUpgrader.java
public static void main(String[] args) { try {/*from w ww. j ava2 s.com*/ StopWatch stopWatch = new StopWatch(); stopWatch.start(); InitUtil.initWithSpring(); upgrade(); verify(); System.out.println("\nSuccessfully completed upgrade process in " + (stopWatch.getTime() / Time.SECOND) + " seconds."); System.exit(0); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }