/** Assembles an aggregated report. */ @Override @SuppressWarnings("PMD.AvoidDuplicateLiterals") protected String assemble(List<PolicyStats> results) { String[][] data = new String[results.size()][headers().length]; for (int i = 0; i < results.size(); i++) { PolicyStats policyStats = results.get(i); data[i] = new String[] { policyStats.name(), String.format("%.2f %%", 100 * policyStats.hitRate()), String.format("%,d", policyStats.hitCount()), String.format("%,d", policyStats.missCount()), String.format("%,d", policyStats.requestCount()), String.format("%,d", policyStats.evictionCount()), String.format("%.2f %%", 100 * policyStats.admissionRate()), steps(policyStats), policyStats.stopwatch().toString() }; } return FlipTable.of(headers(), data); }
public static void run(String label, Benchmark benchmark) throws Exception { // warmup benchmark.run(WARMUP); System.err.print("- "); // run garbage collection System.gc(); System.err.print("- "); // perform timing Stopwatch stopwatch = Stopwatch.createStarted(); benchmark.run(BENCHMARK); System.err.println(label + " " + stopwatch.stop().toString()); }
public void testToString() { stopwatch.start(); assertEquals("0.000 ns", stopwatch.toString()); ticker.advance(1); assertEquals("1.000 ns", stopwatch.toString()); ticker.advance(998); assertEquals("999.0 ns", stopwatch.toString()); ticker.advance(1); assertEquals("1.000 \u03bcs", stopwatch.toString()); ticker.advance(1); assertEquals("1.001 \u03bcs", stopwatch.toString()); ticker.advance(8998); assertEquals("9.999 \u03bcs", stopwatch.toString()); stopwatch.reset(); stopwatch.start(); ticker.advance(1234567); assertEquals("1.235 ms", stopwatch.toString()); stopwatch.reset(); stopwatch.start(); ticker.advance(5000000000L); assertEquals("5.000 s", stopwatch.toString()); stopwatch.reset(); stopwatch.start(); ticker.advance((long) (1.5 * 60 * 1000000000L)); assertEquals("1.500 min", stopwatch.toString()); stopwatch.reset(); stopwatch.start(); ticker.advance((long) (2.5 * 60 * 60 * 1000000000L)); assertEquals("2.500 h", stopwatch.toString()); stopwatch.reset();
/** * Get elapsed time as a string so it can be included in logs */ public String getElapsed() { return elapsed.toString(); }
@Override public String toString() { return stopwatch.get().toString(); }
private static String readdir() { StringBuilder sb = new StringBuilder(); Stopwatch s = Stopwatch.createStarted(); sb.append(new File(dir).listFiles().length); System.out.println("readdir took " + s); System.out.println("num of files " + sb); return s.toString(); }
/** * Returns a string representation of the current elapsed time; equivalent to * {@code toString(4)} (four significant figures). */ @GwtIncompatible("String.format()") @Override public String toString() { return toString(4); }
/** * Returns a string representation of the current elapsed time. */ @GwtIncompatible("String.format()") @Override public String toString() { return toString(4); }
private static String createdirs(int files) { Stopwatch s = Stopwatch.createStarted(); for (int i = 0; i < files; i++) { FilesUtils.mkdirs(dir + i); } System.out.println("createdirs took " + s); return s.toString(); }
private static String createfiles(int files) { Stopwatch s = Stopwatch.createStarted(); for (int i = 0; i < files; i++) { TextFileUtils.setContents(dir + i + "/" + i, "1 " + i); } System.out.println("createfiles took " + s); return s.toString(); }
private static String readfiles(int files) { StringBuilder sb = new StringBuilder(); Stopwatch s = Stopwatch.createStarted(); for (int i = 0; i < files; i++) { sb.append(TextFileUtils.getContents(dir + i + "/" + i)); } System.out.println("readfiles took " + s); return s.toString(); }
@SuppressWarnings("unused") private static String rmdirs(int files) { Stopwatch s = Stopwatch.createStarted(); for (int i = 0; i < files; i++) { FilesUtils.delete(dir + i + "/" + i); FilesUtils.delete(dir + i); } System.out.println("rmdirs took " + s); return s.toString(); }
private void logImportResult(JournalImportAction action, Stopwatch stopwatch) { String msg = String.format("Journals import took %s. Journals: %d (new: %d, modified: %d, unmodified: %d)", stopwatch.toString(), action.getTotalCount(), action.getNewJournalsCount(), action.getModifiedJournalsCount(), action.getUnmodifiedJournalsCount()); logger.info(msg); Set<String> missingPbnIds = action.getMissingPbnIds(); if (! missingPbnIds.isEmpty()) { int count = missingPbnIds.size(); String ids = StringUtils.join(missingPbnIds, ", "); logger.warn("{} journals were not re-imported: {}", count, ids); } }
/** * Value is reported in best suited units (e.g. milliseconds, seconds, minutes etc). * * @param name statistic name * @return human readable (formatted) timer value or 0 (if stat value is not available) * @throws IllegalStateException if provided stat is not time stat */ public String humanTime(final Stat name) { name.requiresTimer(); Preconditions.checkState(name.isTimer(), "Stat %s is not timer stat", name); final Stopwatch stopwatch = tracker.getTimers().get(name); return stopwatch == null ? "0" : stopwatch.toString(); }
private synchronized void populate() { log.info("Populating Matcher Index...");// if index is empty Stopwatch w = new Stopwatch().start(); Set<URI> classes = new HashSet<URI>(this.manager.getKnowledgeBaseManager().listConcepts(null)); Map<URI, Map<URI, MatchResult>> matchesTable = sparqlMatcher.listMatchesAtLeastOfType(classes, LogicConceptMatchType.Subsume).rowMap(); for (URI c : classes) { if (matchesTable.get(c) != null) { indexedMatches.put(c, new ConcurrentHashMap(matchesTable.get(c))); } } log.info("Population done in {}. Number of entries {}", w.stop().toString(), indexedMatches.size()); }
@Override public void cleanUp() { try { localMachines.removeMachine(customizerMachine); MongoClientURI mongoClientURI = new MongoClientURI( checkNotNull(params.get(DB_URI), DB_URI + " param is required")); Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase())); Stopwatch stopwatch = Stopwatch.createStarted(); jongo.getCollection(given.getCollection()).drop(); System.out.printf("dropped %s -- %s%n", given.getCollection(), stopwatch.stop().toString()); } catch (UnknownHostException e) { throw new RuntimeException(e); } } };
private void benchmarkIteration(Iterator<RevCommit> commits) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Stopwatch sw = Stopwatch.createStarted(); sw.reset().start(); int c = 0; while (commits.hasNext()) { c++; commits.next(); } sw.stop(); System.err.println("Iterated " + numberFormat.format(c) + " commits in " + sw.toString()); }
private void benchmarkIteration(Iterator<RevCommit> commits) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Stopwatch sw = Stopwatch.createStarted(); sw.reset().start(); int c = 0; while (commits.hasNext()) { c++; commits.next(); } sw.stop(); System.err.println("Iterated " + numberFormat.format(c) + " commits in " + sw.toString()); }
private void benchmarkIteration(Iterator<RevCommit> commits) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Stopwatch sw = new Stopwatch(); sw.reset().start(); int c = 0; while (commits.hasNext()) { c++; commits.next(); } sw.stop(); System.err.println("Iterated " + numberFormat.format(c) + " commits in " + sw.toString()); }
private void sendNotificationIfNeeded() { if (new NotificationChecker() .shouldSendNotification(snoozeKeeper, collectorInfo, project.name(), node.name(), notificationsCount, result, previousResult)) { notificationDeliverToDatabase .sendCollectorResult(collectorInfo.name(), node, project, result.output(), result.exit(), stopwatch.toString(), true, (int) notificationsCount.size()); } previousResult = result; }