List of usage examples for org.apache.commons.lang.time StopWatch start
public void start()
Start the stopwatch.
This method starts a new timing session, clearing any previous values.
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(); watch.suspend();/*from ww w .j a v a2 s.c om*/ 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:MainClass.java
public static void main(String[] args) { StopWatch stWatch = new StopWatch(); //Start StopWatch stWatch.start(); //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()); }/* www . ja v a2 s .c om*/ //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(); // 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()); }/*from w w w . j ava 2s . co m*/ // Stop StopWatch stWatch.stop(); System.out.println("Time Taken >>" + stWatch.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(); File dir = new File("mutation-files/tmp"); dir.mkdir();/*from www. j a v a2s . c om*/ 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:hadoop.Main.java
public static void main(String[] args) throws Exception { StopWatch timer = new StopWatch(); timer.start(); 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); }// w ww. jav a 2s . co m } timer.stop(); System.out.println("Elapsed " + timer.toString()); }
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 ww w. j a v a 2 s . 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:elaborate.editor.backend.AnnotationMarkerScrubber.java
@SuppressWarnings("boxing") public static void main(String[] args) { StopWatch sw = new StopWatch(); sw.start(); EntityManager entityManager = HibernateUtil.beginTransaction(); TranscriptionService ts = TranscriptionService.instance(); ts.setEntityManager(entityManager);/*from w w w . j av a2 s . c om*/ 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: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(); ElaborateSolrIndexer solr = new ElaborateSolrIndexer(); if (wipeIndexFirst) { Log.info("clearing index"); solr.clear();// www.j a va2s.c o m } 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:gov.nasa.ensemble.common.functional.ParTileExample.java
/** * @param args// www .ja va 2 s . c o m */ public static void main(String[] args) { final StopWatch stopWatch = new StopWatch(); stopWatch.start(); final ExecutorService pool = Executors.newFixedThreadPool(NUM_THREADS); final ParModule pm = ParModule.parModule(Strategy.<Unit>executorStrategy(pool)); final Actor<Tree<Tile>> tileWriter = pm.effect(new Effect<Tree<Tile>>() { @Override public void e(Tree<Tile> tree) { final List<Tile> nodes = tree.flatten().toList(); final Actor<String> callback = pm.actor(new Effect<String>() { final int totalTiles = nodes.length(); int counter = 0; @Override public void e(final String response) { // System.err.println(response); if (++counter >= totalTiles) { final String msg = MessageFormat.format( "All done! Made {0} tiles for a {1} pixel image in {2} seconds", counter, IMAGE_WIDTH * IMAGE_HEIGHT, stopWatch.getTime() / 1000.0); System.err.println(msg); pool.shutdown(); } } }).asActor(); nodes.foreach(Actors.act(pm.effect(new Effect<Tile>() { @Override public void e(final Tile tile) { ThreadUtils.sleep(SAVE_TIME); callback.act("done saving " + tile); } }))); } }); final Image inputImage = new Image(V.v(IMAGE_WIDTH, IMAGE_HEIGHT)); process(inputImage, V.v(0.0, 0.0), 0, pm).to(tileWriter); }
From source file:fr.inria.edelweiss.kgdqp.core.FedQueryingCLI.java
@SuppressWarnings("unchecked") public static void main(String args[]) throws ParseException, EngineException { List<String> endpoints = new ArrayList<String>(); String queryPath = null;/*from ww w . ja v a 2 s. c o m*/ int slice = -1; Options options = new Options(); Option helpOpt = new Option("h", "help", false, "print this message"); Option queryOpt = new Option("q", "query", true, "specify the sparql query file"); Option endpointOpt = new Option("e", "endpoints", true, "the list of federated sparql endpoint URLs"); Option groupingOpt = new Option("g", "grouping", true, "triple pattern optimisation"); Option slicingOpt = new Option("s", "slicing", true, "size of the slicing parameter"); Option versionOpt = new Option("v", "version", false, "print the version information and exit"); options.addOption(queryOpt); options.addOption(endpointOpt); options.addOption(helpOpt); options.addOption(versionOpt); options.addOption(groupingOpt); options.addOption(slicingOpt); String header = "Corese/KGRAM DQP command line interface"; String footer = "\nPlease report any issue to alban.gaignard@cnrs.fr"; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("kgdqp", header, options, footer, true); System.exit(0); } if (!cmd.hasOption("e")) { logger.info("You must specify at least the URL of one sparql endpoint !"); System.exit(0); } else { endpoints = new ArrayList<String>(Arrays.asList(cmd.getOptionValues("e"))); } if (!cmd.hasOption("q")) { logger.info("You must specify a path for a sparql query !"); System.exit(0); } else { queryPath = cmd.getOptionValue("q"); } if (cmd.hasOption("s")) { try { slice = Integer.parseInt(cmd.getOptionValue("s")); } catch (NumberFormatException ex) { logger.warn(cmd.getOptionValue("s") + " is not formatted as number for the slicing parameter"); logger.warn("Slicing disabled"); } } if (cmd.hasOption("v")) { logger.info("version 3.0.4-SNAPSHOT"); System.exit(0); } ///////////////// Graph graph = Graph.create(); QueryProcessDQP exec = QueryProcessDQP.create(graph); exec.setGroupingEnabled(cmd.hasOption("g")); if (slice > 0) { exec.setSlice(slice); } Provider sProv = ProviderImplCostMonitoring.create(); exec.set(sProv); for (String url : endpoints) { try { exec.addRemote(new URL(url), WSImplem.REST); } catch (MalformedURLException ex) { logger.error(url + " is not a well-formed URL"); System.exit(1); } } StringBuffer fileData = new StringBuffer(1000); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(queryPath)); } catch (FileNotFoundException ex) { logger.error("Query file " + queryPath + " not found !"); System.exit(1); } char[] buf = new char[1024]; int numRead = 0; try { while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; } reader.close(); } catch (IOException ex) { logger.error("Error while reading query file " + queryPath); System.exit(1); } String sparqlQuery = fileData.toString(); // Query q = exec.compile(sparqlQuery, null); // System.out.println(q); StopWatch sw = new StopWatch(); sw.start(); Mappings map = exec.query(sparqlQuery); int dqpSize = map.size(); System.out.println("--------"); long time = sw.getTime(); System.out.println(time + " " + dqpSize); }