List of usage examples for com.google.common.base Stopwatch elapsed
@CheckReturnValue public long elapsed(TimeUnit desiredUnit)
From source file:com.jejking.hh.nord.app.CreateGazetteer.java
/** * @param args/* w ww . j a v a 2 s.c om*/ */ public static void main(String[] args) { Stopwatch stopwatch = Stopwatch.createStarted(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]); registerShutdownHook(graph); // we want an additional index on adminstrative area - name setupSchema(graph); System.out.println("Setup indexes. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); CreatePartialGazetteerWithOpenData.writeHamburgPolygons(graph); System.out.println( "Wrote hamburg polygons. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); WriteStreets.writeStreets(geometryFactory, graph); System.out.println("Wrote streets. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); MapStreetsToPolygons.mapStreetsToAdminPolygons(graph); System.out.println( "Linked streets to polygons. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); WritePointsOfInterest.writePointsOfInterest(geometryFactory, graph); System.out.println( "Wrote points of interest. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); graph.shutdown(); System.out.println("Done. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); }
From source file:com.google.devtools.build.android.LibraryRClassGeneratorAction.java
public static void main(String[] args) throws Exception { final Stopwatch timer = Stopwatch.createStarted(); OptionsParser optionsParser = OptionsParser.newOptionsParser(Options.class, AaptConfigOptions.class); optionsParser.parseAndExitUponError(args); AaptConfigOptions aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class); Options options = optionsParser.getOptions(Options.class); logger.fine(String.format("Option parsing finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); try (ScopedTemporaryDirectory scopedTmp = new ScopedTemporaryDirectory("android_resource_generated")) { AndroidResourceClassWriter resourceClassWriter = AndroidResourceClassWriter.createWith( aaptConfigOptions.androidJar, scopedTmp.getPath(), Strings.nullToEmpty(options.packageForR)); resourceClassWriter.setIncludeClassFile(true); resourceClassWriter.setIncludeJavaFile(false); final AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger); logger.fine(String.format("Setup finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); final ParsedAndroidData data = resourceProcessor.deserializeSymbolsToData(options.symbols); logger.fine(String.format("Deserialization finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); data.writeResourcesTo(resourceClassWriter); resourceClassWriter.flush();/*from www.jav a2s . co m*/ logger.fine(String.format("R writing finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); resourceProcessor.createClassJar(scopedTmp.getPath(), options.classJarOutput); logger.fine(String.format("Creating class jar finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); } catch (IOException | MergingException | DeserializationException e) { logger.log(Level.SEVERE, "Errors during R generation.", e); throw e; } }
From source file:org.apache.drill.exec.RunRootExec.java
public static void main(String args[]) throws Exception { String path = args[0];/*from ww w. j a v a 2 s. c om*/ int iterations = Integer.parseInt(args[1]); Drillbit bit = new Drillbit(c, RemoteServiceSet.getLocalServiceSet()); bit.run(); DrillbitContext bitContext = bit.getContext(); PhysicalPlanReader reader = bitContext.getPlanReader(); PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(new File(path), Charsets.UTF_8)); FunctionImplementationRegistry registry = bitContext.getFunctionImplementationRegistry(); FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), null, registry); SimpleRootExec exec; for (int i = 0; i < iterations; i++) { Stopwatch w = new Stopwatch().start(); System.out.println("STARTITER:" + i); exec = new SimpleRootExec( ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); while (exec.next()) { for (ValueVector v : exec) { v.clear(); } } System.out.println("ENDITER: " + i); System.out.println("TIME: " + w.elapsed(TimeUnit.MILLISECONDS) + "ms"); exec.close(); } context.close(); bit.close(); }
From source file:org.hyperledger.perftest.PerfTestApp.java
public static void main(String[] args) throws Exception { Stopwatch watch = Stopwatch.createStarted(); System.setProperty("logback.configurationFile", "logback.xml"); int rounds = Integer.parseInt(args[2]); int count = Integer.parseInt(args[3]); // int threadCount = Integer.parseInt(args[4]); int threadCount = 1; PerfTestApp app = new PerfTestApp(rounds, count, threadCount); app.measure(app.bcsapi);/* w ww.ja va2 s . c o m*/ app.stop(); watch.stop(); System.out.println("DONE in " + watch.elapsed(TimeUnit.SECONDS) + " seconds"); System.exit(0); }
From source file:end2end.Profiling.java
public static void main(String[] args) { try {//ww w.ja v a2s.co m String line = "------------------------------"; System.out.println(line); System.out.println("EvoRS console"); System.out.println(line); final Stopwatch stopwatch = Stopwatch.createStarted(); System.out.println("Starting..."); RobotExperiment exp; exp = RobotExperiment.fromDirectory(System.getProperty("user.dir") + "/demo/"); //load the demo layout and world final RobotGARunner gaRunner = new RobotGARunner(new RobotPhenotype(exp), true); System.out.println(""); System.out.printf("Initialised in %d milliseconds\n", stopwatch.elapsed(TimeUnit.MILLISECONDS)); System.out.println(line); System.out.println(""); System.out.println(gaRunner.getProgressReportHeader()); gaRunner.setListener(new RobotGARunner.GAListener() { long lastGenTime = -1; @Override public void doUpdate() { if (lastGenTime != -1) System.out.printf("Generation done in %d milliseconds\n", stopwatch.elapsed(TimeUnit.MILLISECONDS) - lastGenTime); lastGenTime = stopwatch.elapsed(TimeUnit.MILLISECONDS); System.out.println(gaRunner.getProgressReportLine()); } @Override public void finished() { System.out.printf("Finished in %d milliseconds\n", stopwatch.elapsed(TimeUnit.MILLISECONDS)); } }); new Thread(gaRunner).start(); } catch (IOException ex) { Logger.getLogger(Profiling.class.getName()).log(Level.SEVERE, null, ex); System.exit(1); } }
From source file:com.google.devtools.build.android.ZipFilterAction.java
public static void main(String[] args) throws IOException { Options options = new Options(); new JCommander(options).parse(args); logger.fine(String.format("Creating filter from entries of type %s, in zip files %s.", options.filterTypes, options.filterZips));/*from w w w . java2 s .c o m*/ final Stopwatch timer = Stopwatch.createStarted(); final Multimap<String, Long> entriesToOmit = getEntriesToOmit(options.filterZips, options.filterTypes); final String explicitFilter = options.explicitFilters.isEmpty() ? "" : String.format(".*(%s).*", Joiner.on("|").join(options.explicitFilters)); logger.fine(String.format("Filter created in %dms", timer.elapsed(TimeUnit.MILLISECONDS))); ImmutableMap.Builder<String, Long> inputEntries = ImmutableMap.builder(); try (ZipReader input = new ZipReader(options.inputZip.toFile())) { for (ZipFileEntry entry : input.entries()) { inputEntries.put(entry.getName(), entry.getCrc()); } } ZipEntryFilter entryFilter = new ZipFilterEntryFilter(explicitFilter, entriesToOmit, inputEntries.build(), options.errorOnHashMismatch); try (OutputStream out = Files.newOutputStream(options.outputZip); ZipCombiner combiner = new ZipCombiner(options.outputMode, entryFilter, out)) { combiner.addZip(options.inputZip.toFile()); } logger.fine(String.format("Filtering completed in %dms", timer.elapsed(TimeUnit.MILLISECONDS))); }
From source file:eu.amidst.core.inference.messagepassing.ParallelVMP.java
public static void main(String[] arguments) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/Munin1.bn"); System.out.println(bn.getNumberOfVars()); System.out.println(bn.getConditionalDistributions().stream().mapToInt(p -> p.getNumberOfParameters()).max() .getAsInt());/*from w w w.j a v a 2s .c o m*/ ParallelVMP vmp = new ParallelVMP(); InferenceEngine.setInferenceAlgorithm(vmp); Variable var = bn.getVariables().getVariableById(0); UnivariateDistribution uni = null; double avg = 0; for (int i = 0; i < 20; i++) { Stopwatch watch = Stopwatch.createStarted(); uni = InferenceEngine.getPosterior(var, bn); System.out.println(watch.stop()); avg += watch.elapsed(TimeUnit.MILLISECONDS); } System.out.println(avg / 20); System.out.println(uni); }
From source file:com.github.ibole.infrastructure.security.jwt.auth0.Auth0Utils.java
public static void main(String[] args) throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC"); keyPairGenerator.initialize(256);//w ww. ja va 2 s . com KeyPair keyPair = keyPairGenerator.generateKeyPair(); ECPublicKey ecPublicKey = (ECPublicKey) keyPair.getPublic(); ECPrivateKey ecPrivateKey = (ECPrivateKey) keyPair.getPrivate(); JwtObject jwt = new JwtObject(); jwt.setAudience("audience"); jwt.setClientId("clientId"); jwt.setIssuer("issuer"); jwt.setLoginId("loginId"); jwt.setSubject("subject"); jwt.setTtlSeconds(5); jwt.getRoles().add("admin"); final Stopwatch stopwatch = Stopwatch.createStarted(); String token = createJwtWithECKey(jwt, ecPublicKey, ecPrivateKey); TokenValidationCallback<DecodedJWT> callback = new BaseTokenValidationCallback<DecodedJWT>(); validateToken(token, jwt.getClientId(), ecPublicKey, ecPrivateKey, callback); //Thread.currentThread().sleep(9000); JwtObject newjwt = claimsOfTokenWithoutValidation(token, ecPublicKey, ecPrivateKey); String elapsedString = Long.toString(stopwatch.elapsed(TimeUnit.MILLISECONDS)); System.out.println("Spent: " + elapsedString); System.out.println(callback.getTokenStatus()); System.out.println(token); }
From source file:ec.jwsacruncher.App.java
/** * @param args the command line arguments *//* w w w. j av a 2s .co m*/ public static void main(String[] args) { Stopwatch stopwatch = Stopwatch.createStarted(); Entry<File, WsaConfig> config = ArgsDecoder.decodeArgs(args); if (config == null) { System.out.println("Wrong arguments"); return; } if (args == null || args.length == 0) { return; } if (config.getValue() == null) { return; } loadResources(); enableDiagnostics(config.getValue().Matrix); try (FileWorkspace ws = FileWorkspace.open(config.getKey().toPath())) { process(ws, ProcessingContext.getActiveContext(), config.getValue()); } catch (IOException ex) { log.log(Level.SEVERE, null, ex); } System.out.println("Total processing time: " + stopwatch.elapsed(TimeUnit.SECONDS) + "s"); }
From source file:com.paolodragone.wsn.domain.PopulateDatabase.java
public static void main(String[] args) { try {/*from www . j av a 2 s . c o m*/ // Readers WsnConfiguration configuration = WsnConfiguration.getInstance(); Path semanticNetworkFilePath = configuration.getSemanticNetworkFilePath(); Reader sensesFileReader = Files.newBufferedReader(configuration.getSensesFilePath()); Reader termsFileReader = Files.newBufferedReader(configuration.getTermsFilePath()); Reader semanticNetworkFileReader = Files.newBufferedReader(semanticNetworkFilePath); // Get sense Stream SensesDataSet sensesDataSet = new SensesDataSet(); SensesDataSet sensesDataSetView; sensesDataSetView = sensesDataSet .getView(sensesDataSet.excludeColumns(SensesDataSet.SenseColumn.Gloss)); Stream<com.paolodragone.wsn.entities.Sense> senseStream = sensesDataSetView .getEntityStream(sensesFileReader).parallel(); senseStream = Senses.filterValidSenses(senseStream); Collection<com.paolodragone.wsn.entities.Sense> senses = DStreamSupport.toList(senseStream); Map<Integer, com.paolodragone.wsn.entities.Sense> senseMap = DCollections.collectionToMap(senses, com.paolodragone.wsn.entities.Sense::getId, new HashMap<>()); // Set terms TermsDataSet termsDataSet = new TermsDataSet(); Stream<com.paolodragone.wsn.entities.Term> termStream = termsDataSet.getEntityStream(termsFileReader); TermsDataSet.setTerms(senseMap, termStream); { } senseMap = null; SemanticNetworkDataSet semanticNetworkDataSet = new SemanticNetworkDataSet(); Stream<SemanticEdge> semanticNetworkStream; semanticNetworkStream = semanticNetworkDataSet.getEntityStream(semanticNetworkFileReader); Collection<SemanticEdge> semanticNetwork = DStreamSupport.toList(semanticNetworkStream); Map<Integer, SemanticEdge> semanticNetworkMap = DCollections.collectionToMap(semanticNetwork, SemanticEdge::getTermId, new HashMap<>()); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("wsn_unit"); EntityManager entityManager = entityManagerFactory.createEntityManager(); Stopwatch stopwatch = Stopwatch.createStarted(); long lastElapsed = 0; Map<Integer, DomainSense> domainSenseMap = new LinkedHashMap<>(); entityManager.getTransaction().begin(); int senseCount = 0; for (Sense sense : senses) { DomainSense domainSense = new DomainSense(); domainSense.setId(sense.getId()); domainSense.setWord(sense.getWord()); domainSense.setPos(sense.getPos()); domainSense.setNumber(sense.getNumber()); entityManager.persist(domainSense); domainSenseMap.put(domainSense.getId(), domainSense); senseCount++; long elapsed = stopwatch.elapsed(TimeUnit.SECONDS); if (elapsed > lastElapsed) { lastElapsed = elapsed; System.out.print("\rSenses: " + senseCount); entityManager.flush(); entityManager.clear(); } } entityManager.getTransaction().commit(); entityManager.clear(); entityManager.getTransaction().begin(); System.out.println("\n"); int termCount = 0; for (Sense sense : senses) { DomainSense domainSense = domainSenseMap.get(sense.getId()); List<Term> terms = sense.getGlossTerms(); for (Term term : terms) { DomainTerm domainTerm = new DomainTerm(); domainTerm.setId(term.getId()); domainTerm.setWord(term.getWord()); domainTerm.setLemma(term.getLemma()); domainTerm.setPos(term.getPos()); domainTerm.setPosition(term.getPosition()); domainTerm.setSense(domainSense); SemanticEdge semanticEdge = semanticNetworkMap.get(term.getId()); if (semanticEdge != null) { DomainSense targetDomainSense = domainSenseMap.get(semanticEdge.getTargetSenseId()); double confidence = semanticEdge.getConfidence(); domainTerm.setTargetSense(targetDomainSense); domainTerm.setConfidence(confidence); } entityManager.persist(domainTerm); termCount++; long elapsed = stopwatch.elapsed(TimeUnit.SECONDS); if (elapsed > lastElapsed) { lastElapsed = elapsed; System.out.print("\rTerms: " + termCount); entityManager.flush(); entityManager.clear(); } } } entityManager.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } }