List of usage examples for com.google.common.base Stopwatch createStarted
@CheckReturnValue public static Stopwatch createStarted()
From source file:com.google.devtools.build.android.ResourceShrinkerAction.java
public static void main(String[] args) throws Exception { final Stopwatch timer = Stopwatch.createStarted(); // Parse arguments. OptionsParser optionsParser = OptionsParser.newOptionsParser(Options.class, AaptConfigOptions.class); optionsParser.parseAndExitUponError(args); aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class); options = optionsParser.getOptions(Options.class); AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger); // Setup temporary working directories. try (ScopedTemporaryDirectory scopedTmp = new ScopedTemporaryDirectory("resource_shrinker_tmp")) { Path working = scopedTmp.getPath(); final Path resourceFiles = working.resolve("resource_files"); final Path shrunkResources = working.resolve("shrunk_resources"); // Gather package list from manifests. Set<String> resourcePackages = getManifestPackages(options.primaryManifest, options.dependencyManifests); resourcePackages.addAll(options.resourcePackages); // Expand resource files zip into working directory. try (ZipInputStream zin = new ZipInputStream(new FileInputStream(options.resourcesZip.toFile()))) { ZipEntry entry;//from ww w. j a v a 2 s . c o m while ((entry = zin.getNextEntry()) != null) { if (!entry.isDirectory()) { Path output = resourceFiles.resolve(entry.getName()); Files.createDirectories(output.getParent()); try (FileOutputStream fos = new FileOutputStream(output.toFile())) { ByteStreams.copy(zin, fos); } } } } // Shrink resources. ResourceUsageAnalyzer resourceShrinker = new ResourceUsageAnalyzer(resourcePackages, options.rTxt, options.shrunkJar, options.primaryManifest, options.proguardMapping, resourceFiles.resolve("res"), options.log); resourceShrinker.shrink(shrunkResources); logger.fine( String.format("Shrinking resources finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); Path generatedSources = null; if (options.rTxtOutput != null) { generatedSources = working.resolve("generated_resources"); } // Build ap_ with shrunk resources. resourceProcessor.processResources(aaptConfigOptions.aapt, aaptConfigOptions.androidJar, aaptConfigOptions.buildToolsVersion, VariantType.DEFAULT, aaptConfigOptions.debug, null /* packageForR */, new FlagAaptOptions(aaptConfigOptions), aaptConfigOptions.resourceConfigs, aaptConfigOptions.splits, new MergedAndroidData(shrunkResources, resourceFiles.resolve("assets"), options.primaryManifest), ImmutableList.<DependencyAndroidData>of() /* libraries */, generatedSources, options.shrunkApk, null /* proguardOutput */, null /* mainDexProguardOutput */, null /* publicResourcesOut */, null /* dataBindingInfoOut */); if (options.shrunkResources != null) { resourceProcessor.createResourcesZip(shrunkResources, resourceFiles.resolve("assets"), options.shrunkResources, false /* compress */); } if (options.rTxtOutput != null) { resourceProcessor.copyRToOutput(generatedSources, options.rTxtOutput, options.packageType == VariantType.LIBRARY); } logger.fine(String.format("Packing resources finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); } catch (Exception e) { logger.log(Level.SEVERE, "Error shrinking resources", e); throw e; } finally { resourceProcessor.shutdown(); } }
From source file:com.davidbracewell.math.linear.MatrixMath.java
/** * The entry point of application.//from www . j ava 2 s. c o m * * @param args the input arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { Matrix m1 = randomMatrix(10000, 10000); Matrix m2 = randomMatrix(10000, 10000); Stopwatch sw = Stopwatch.createStarted(); Matrix m3 = m1.multiply(m2); sw.stop(); System.out.println(sw); // System.out.println(m3); // // m1 = new SparseMatrix(2, 3); // m1.set(0, 0, 1); // m1.set(0, 1, 2); // m1.set(0, 2, 3); // m1.set(1, 0, 4); // m1.set(1, 1, 5); // m1.set(1, 2, 6); // // m2 = new SparseMatrix(3, 2); // m2.set(0, 0, 7); // m2.set(0, 1, 8); // m2.set(1, 0, 9); // m2.set(1, 1, 10); // m2.set(2, 0, 11); // m2.set(2, 1, 12); // // m3 = m1.multiply(m2); // System.out.println(m3); }
From source file:com.github.benmanes.caffeine.cache.simulator.parser.wikipedia.Compactor.java
public static void main(String[] args) throws Exception { checkArgument(args.length == 2, "Compactor [input file] [output file]"); Compactor compactor = new Compactor(Paths.get(args[0]), Paths.get(args[1])); Stopwatch stopwatch = Stopwatch.createStarted(); compactor.run();//from w w w.j a va 2 s .com System.out.println("Executed in " + stopwatch); }
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 ww w. ja v a 2 s . co 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:org.opendaylight.netconf.test.tool.client.stress.StressClient.java
public static void main(final String[] args) { params = parseArgs(args, Parameters.getParser()); params.validate();/* w ww. j a v a 2 s. c o m*/ final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory .getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(params.debug ? Level.DEBUG : Level.INFO); final int threadAmount = params.threadAmount; LOG.info("thread amount: " + threadAmount); final int requestsPerThread = params.editCount / params.threadAmount; LOG.info("requestsPerThread: " + requestsPerThread); final int leftoverRequests = params.editCount % params.threadAmount; LOG.info("leftoverRequests: " + leftoverRequests); LOG.info("Preparing messages"); // Prepare all msgs up front final List<List<NetconfMessage>> allPreparedMessages = new ArrayList<>(threadAmount); for (int i = 0; i < threadAmount; i++) { if (i != threadAmount - 1) { allPreparedMessages.add(new ArrayList<NetconfMessage>(requestsPerThread)); } else { allPreparedMessages.add(new ArrayList<NetconfMessage>(requestsPerThread + leftoverRequests)); } } final String editContentString; try { editContentString = Files.toString(params.editContent, Charsets.UTF_8); } catch (final IOException e) { throw new IllegalArgumentException("Cannot read content of " + params.editContent); } for (int i = 0; i < threadAmount; i++) { final List<NetconfMessage> preparedMessages = allPreparedMessages.get(i); int padding = 0; if (i == threadAmount - 1) { padding = leftoverRequests; } for (int j = 0; j < requestsPerThread + padding; j++) { LOG.debug("id: " + (i * requestsPerThread + j)); preparedMessages.add(prepareMessage(i * requestsPerThread + j, editContentString)); } } final NioEventLoopGroup nioGroup = new NioEventLoopGroup(); final Timer timer = new HashedWheelTimer(); final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(params, nioGroup, timer); final List<StressClientCallable> callables = new ArrayList<>(threadAmount); for (final List<NetconfMessage> messages : allPreparedMessages) { callables.add(new StressClientCallable(params, netconfClientDispatcher, messages)); } final ExecutorService executorService = Executors.newFixedThreadPool(threadAmount); LOG.info("Starting stress test"); final Stopwatch started = Stopwatch.createStarted(); try { final List<Future<Boolean>> futures = executorService.invokeAll(callables); for (final Future<Boolean> future : futures) { try { future.get(4L, TimeUnit.MINUTES); } catch (ExecutionException | TimeoutException e) { throw new RuntimeException(e); } } executorService.shutdownNow(); } catch (final InterruptedException e) { throw new RuntimeException("Unable to execute requests", e); } started.stop(); LOG.info("FINISHED. Execution time: {}", started); LOG.info("Requests per second: {}", (params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS))); // Cleanup timer.stop(); try { nioGroup.shutdownGracefully().get(20L, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.warn("Unable to close executor properly", e); } //stop the underlying ssh thread that gets spawned if we use ssh if (params.ssh) { AsyncSshHandler.DEFAULT_CLIENT.stop(); } }
From source file:org.apache.tez.log.LogParser.java
public static void main(String[] args) throws IOException { Preconditions.checkArgument(args.length == 1, "Please provide the file to be parsed"); File inputFile = new File(args[0]); Preconditions.checkArgument(inputFile.exists(), "Please provide valid file. " + inputFile + " does not exist"); Stopwatch sw = Stopwatch.createStarted(); LogParser parser = new LogParser(inputFile); parser.process();/*ww w . jav a2 s . c o m*/ System.out.println(); IAnalyzer vertexMappingAnalyzer = parser.getAnalyzers().get(VertexMappingAnalyzer.class.getName()); IAnalyzer vertexFinishedAnalyzer = parser.getAnalyzers().get(VertexFinishedAnalyzer.class.getName()); if (vertexMappingAnalyzer != null && vertexFinishedAnalyzer != null) { System.out.println("Vertices that haven't finished"); System.out.println("*******************************"); Map<String, String> vertexMapping = (Map<String, String>) vertexMappingAnalyzer.getResult(); Map<VertexFinishedAnalyzer.VertexFinished, String> vertexFinishedMap = (Map<VertexFinishedAnalyzer.VertexFinished, String>) vertexFinishedAnalyzer .getResult(); for (Map.Entry<String, String> e : vertexMapping.entrySet()) { boolean found = false; for (Map.Entry<VertexFinishedAnalyzer.VertexFinished, String> fe : vertexFinishedMap.entrySet()) { if (fe.getKey().vertexId.equalsIgnoreCase(e.getKey())) { found = true; break; } } if (!found) { System.out.println(e.getKey() + " is not in finished map list. " + e.getValue()); } } } /** * In case shuffle-blamed-for details is there, co-relate with rack details */ IAnalyzer shuffleBlamedFor = parser.getAnalyzers().get(ShuffleBlamedForAnalyzer.class.getName()); IAnalyzer rackResolver = parser.getAnalyzers().get(RackResolverExtractor.class.getName()); if (shuffleBlamedFor != null && rackResolver != null) { // machine --> rack mapping Map<String, String> rackMap = (Map<String, String>) rackResolver.getResult(); ShuffleBlamedForAnalyzer.ShuffleBlamedForResult result = (ShuffleBlamedForAnalyzer.ShuffleBlamedForResult) shuffleBlamedFor .getResult(); parser.addAdditionalAnalysis("Source machine details..", true); for (String srcMachine : result.getSrcMachines()) { //machine:45454, containerPriority= 8, containerResources=<memory:3584, vCores:1> String machine = srcMachine.substring(0, srcMachine.indexOf(":")); parser.addAdditionalAnalysis(machine + " --> " + rackMap.get(machine)); } parser.addAdditionalAnalysis(""); parser.addAdditionalAnalysis(""); parser.addAdditionalAnalysis("Fetcher machine details..", true); for (String fetcherMachine : result.getFetcherMachines()) { //machine:45454, containerPriority= 8, containerResources=<memory:3584, vCores:1> String machine = fetcherMachine.substring(0, fetcherMachine.indexOf(":")); parser.addAdditionalAnalysis(machine + " --> " + rackMap.get(machine)); } } /** * For containers timeouts. Relate ContainerTimeoutAnalyzer and NodesAnalyzer * */ IAnalyzer containerTimeoutAnalyzer = parser.getAnalyzers().get(ContainerTimeoutAnalyzer.class.getName()); IAnalyzer nodesAnalyzer = parser.getAnalyzers().get(NodesAnalyzer.class.getName()); if (nodesAnalyzer != null && containerTimeoutAnalyzer != null) { List<String> containersWithTimeout = (List<String>) containerTimeoutAnalyzer.getResult(); // Node --> <attempt, container> Map<String, Map<String, String>> nodesResult = (Map<String, Map<String, String>>) nodesAnalyzer .getResult(); parser.addAdditionalAnalysis(""); parser.addAdditionalAnalysis("Container time outs and attempt/node details", true); for (String container : containersWithTimeout) { for (Map.Entry<String, Map<String, String>> nodeEntry : nodesResult.entrySet()) { Map<String, String> attemptToContainer = nodeEntry.getValue(); for (Map.Entry<String, String> attemptEntry : attemptToContainer.entrySet()) { if (attemptEntry.getValue().equalsIgnoreCase(container)) { parser.addAdditionalAnalysis( container + " --> " + nodeEntry.getKey() + " --> " + attemptEntry.getKey()); } } } } parser.addAdditionalAnalysis(""); } /** * Task attempts not finished */ IAnalyzer taskAttemptStarted = parser.getAnalyzers().get(TaskAttemptStartedAnalyzer.class.getName()); IAnalyzer taskAttemptFinished = parser.getAnalyzers().get(TaskAttemptFinishedAnalyzer.class.getName()); if (taskAttemptFinished != null && taskAttemptStarted != null) { Map<String, TaskAttemptStartedAnalyzer.TaskAttemptStarted> started = (Map<String, TaskAttemptStartedAnalyzer.TaskAttemptStarted>) taskAttemptStarted .getResult(); Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished> finished = (Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished>) taskAttemptFinished .getResult(); parser.addAdditionalAnalysis( "List of unfinished tasks!! started=" + started.size() + ", " + "finished=" + finished.size(), true); for (String task : started.keySet()) { //check if this task is in finished keys if (!finished.keySet().contains(task)) { parser.addAdditionalAnalysis(task + " is not in finished list"); } } } /** * For swimlanes (not including killed tasks) */ /* TODO: Need to work on this. IAnalyzer nodeAnalyzer = parser.getAnalyzers() .get(NodesAnalyzer.class.getName()); IAnalyzer taFinishedAnalyzer = parser.getAnalyzers() .get(TaskAttemptFinishedAnalyzer.class.getName()); if (nodeAnalyzer != null && taFinishedAnalyzer != null) { // machine --> task --> container Map<String, Map<String, String>> nodes = (Map<String, Map<String, String>>) nodeAnalyzer.getResult(); // taskIDStr --> taskAttemptFinished Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished> taFinishedMap = (Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished>) taFinishedAnalyzer.getResult(); //Dirty hack to get all DAG Set<String> allDags = Sets.newHashSet(); for(Map.Entry<String, Map<String, String>> entry : nodes.entrySet()) { for (Map.Entry<String, String> taskEntry : entry.getValue().entrySet()) { String taskId = taskEntry.getKey(); //attempt_1478350923850_0006_7 allDags.add(taskId.substring(0, 28)); } } // Construct a map of machine_container --> List<TaskAttemptId> from analyzer dataset. final Map<String, TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>> mapping = Maps.newHashMap(); long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; for(String dag : allDags) { for (Map.Entry<String, Map<String, String>> entry : nodes.entrySet()) { for (Map.Entry<String, String> taskEntry : entry.getValue().entrySet()) { String machine = entry.getKey(); String taskId = taskEntry.getKey(); String containerId = taskEntry.getValue(); if (!taskId.contains("1478350923850_0006_9")) { continue; } String machineContainer = machine + "_" + containerId; TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished> attempts = mapping.get (machineContainer); if (attempts == null) { attempts = new TreeSet<>( new Comparator<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>() { @Override public int compare(TaskAttemptFinishedAnalyzer.TaskAttemptFinished o1, TaskAttemptFinishedAnalyzer.TaskAttemptFinished o2) { if (Long.parseLong(o1.startTime) < Long.parseLong(o2.startTime)) { return -1; } else if (Long.parseLong(o1.startTime) > Long.parseLong(o2.startTime)) { return 1; } else { return 0; } } }); mapping.put(machineContainer, attempts); } //Check if the attempt id is available in finished maps if (taFinishedMap.containsKey(taskId)) { TaskAttemptFinishedAnalyzer.TaskAttemptFinished attempt = taFinishedMap.get(taskId); attempts.add(attempt); if (Long.parseLong(attempt.finishTime) >= maxTime) { maxTime = Long.parseLong(attempt.finishTime); } else if (Long.parseLong(attempt.startTime) <= minTime) { minTime = Long.parseLong(attempt.startTime); } } } } } // draw SVG System.out.println("MinTime: " + minTime + ". maxTime: " + maxTime); SVGUtils svg = new SVGUtils(minTime, maxTime, new TreeSet(mapping.keySet())); int yOffset = 1; for(Map.Entry<String, TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>> entry : mapping.entrySet()) { for (TaskAttemptFinishedAnalyzer.TaskAttemptFinished task : entry.getValue()) { //draw lines svg.drawStep(task.vertexId, Long.parseLong(task.startTime), Long.parseLong(task .timeTaken), yOffset, "LightGreen"); } yOffset++; } svg.saveFileStr("/tmp/test.svg"); System.out.println("Wrote to /tmp/test.svg"); // Now generate the swimlane. } */ System.out.println(); parser.writeAnalysis(); System.out.println("Time taken " + (sw.elapsed(TimeUnit.SECONDS)) + " seconds"); sw.stop(); }
From source file:com.google.devtools.build.android.AndroidResourceProcessingAction.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 = optionsParser.getOptions(AaptConfigOptions.class); options = optionsParser.getOptions(Options.class); final AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(STD_LOGGER); try (ScopedTemporaryDirectory scopedTmp = new ScopedTemporaryDirectory("android_resources_tmp")) { final Path tmp = scopedTmp.getPath(); final Path mergedAssets = tmp.resolve("merged_assets"); final Path mergedResources = tmp.resolve("merged_resources"); final Path filteredResources = tmp.resolve("resources-filtered"); final Path densityManifest = tmp.resolve("manifest-filtered/AndroidManifest.xml"); final Path processedManifest = tmp.resolve("manifest-processed/AndroidManifest.xml"); final Path dummyManifest = tmp.resolve("manifest-aapt-dummy/AndroidManifest.xml"); Path generatedSources = null; if (options.srcJarOutput != null || options.rOutput != null || options.symbolsOut != null) { generatedSources = tmp.resolve("generated_resources"); }//from ww w . j a v a2 s .c om logger.fine(String.format("Setup finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); List<DependencyAndroidData> data = ImmutableSet.<DependencyAndroidData>builder() .addAll(options.directData).addAll(options.transitiveData).build().asList(); final MergedAndroidData mergedData = resourceProcessor.mergeData(options.primaryData, options.directData, options.transitiveData, mergedResources, mergedAssets, selectPngCruncher(), options.packageType, options.symbolsOut); logger.fine(String.format("Merging finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); final DensityFilteredAndroidData filteredData = mergedData.filter( new DensitySpecificResourceFilter(options.densities, filteredResources, mergedResources), new DensitySpecificManifestProcessor(options.densities, densityManifest)); logger.fine(String.format("Density filtering finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); MergedAndroidData processedData = resourceProcessor.processManifest(options.packageType, options.packageForR, options.applicationId, options.versionCode, options.versionName, filteredData, processedManifest); // Write manifestOutput now before the dummy manifest is created. if (options.manifestOutput != null) { resourceProcessor.copyManifestToOutput(processedData, options.manifestOutput); } if (options.packageType == VariantType.LIBRARY) { resourceProcessor.writeDummyManifestForAapt(dummyManifest, options.packageForR); processedData = new MergedAndroidData(processedData.getResourceDir(), processedData.getAssetDir(), dummyManifest); } resourceProcessor.processResources(aaptConfigOptions.aapt, aaptConfigOptions.androidJar, aaptConfigOptions.buildToolsVersion, options.packageType, aaptConfigOptions.debug, options.packageForR, new FlagAaptOptions(aaptConfigOptions), aaptConfigOptions.resourceConfigs, aaptConfigOptions.splits, processedData, data, generatedSources, options.packagePath, options.proguardOutput, options.mainDexProguardOutput, options.resourcesOutput != null ? processedData.getResourceDir().resolve("values").resolve("public.xml") : null, options.dataBindingInfoOut); logger.fine(String.format("aapt finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); if (options.srcJarOutput != null) { resourceProcessor.createSrcJar(generatedSources, options.srcJarOutput, VariantType.LIBRARY == options.packageType); } if (options.rOutput != null) { resourceProcessor.copyRToOutput(generatedSources, options.rOutput, VariantType.LIBRARY == options.packageType); } if (options.resourcesOutput != null) { resourceProcessor.createResourcesZip(processedData.getResourceDir(), processedData.getAssetDir(), options.resourcesOutput, false /* compress */); } logger.fine(String.format("Packaging finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS))); } catch (MergingException e) { logger.log(java.util.logging.Level.SEVERE, "Error during merging resources", e); throw e; } catch (IOException | InterruptedException | LoggedErrorException | UnrecognizedSplitsException e) { logger.log(java.util.logging.Level.SEVERE, "Error during processing resources", e); throw e; } catch (Exception e) { logger.log(java.util.logging.Level.SEVERE, "Unexpected", e); throw e; } finally { resourceProcessor.shutdown(); } logger.fine(String.format("Resources processed in %sms", timer.elapsed(TimeUnit.MILLISECONDS))); }
From source file:eu.amidst.core.inference.messagepassing.VMP.java
public static void main(String[] arguments) throws IOException, ClassNotFoundException { BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/dataWeka/Munin1.bn"); System.out.println(bn.getNumberOfVars()); System.out.println(bn.getDAG().getNumberOfLinks()); System.out.println(bn.getConditionalDistributions().stream().mapToInt(p -> p.getNumberOfParameters()).max() .getAsInt());/*from w w w . j a v a 2s. com*/ VMP vmp = new VMP(); 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:ezbake.data.common.LoggingUtils.java
public static Stopwatch createStopWatch() { return Stopwatch.createStarted(); }
From source file:com.omnius.watcheye.util.PollingVerifier.java
public static void pollingVerify(Runnable verify) { AssertionError lastVerification; Stopwatch watch = Stopwatch.createStarted(); do {/*from ww w. ja va2 s . c o m*/ try { verify.run(); return; } catch (AssertionError e) { lastVerification = e; try { Thread.sleep(VERIFYING_POLL_PERIOD_IN_MILLIS); } catch (InterruptedException e1) { Throwables.propagate(e1); } } } while (watch.elapsed(TimeUnit.MILLISECONDS) < VERIFYING_POLL_TIMEOUT_IN_MILLIS); throw lastVerification; }