public static String formatFilesystemStatistics(FilesystemStatisticsAggregator filesystemStatistics) { return FormatUtils.formatDouble(filesystemStatistics.getUsedPercentage()) + "% used, " + FormatUtils.formatNumBytes(filesystemStatistics.getUsedSpace()) + "/" + FormatUtils.formatNumBytes(filesystemStatistics.getTotalSpace()) ; }
public String getStats() { long totalDurationMs = getTotalDurationMs(); long averageDurationMs = 0; if (durationsMs.size() > 0) { averageDurationMs = totalDurationMs / durationsMs.size(); } StringBuilder logStr = new StringBuilder(); logStr.append("Statistics for: "); logStr.append(name); logStr.append(", average duration: "); logStr.append(FormatUtils.formatSecondsDuration(averageDurationMs / 1000)); logStr.append(", total duration: "); logStr.append(FormatUtils.formatSecondsDuration(totalDurationMs / 1000)); logStr.append(", count: "); logStr.append(durationsMs.size()); return logStr.toString(); }
private static void createZeroFile(String path, long numRecords, int bufferSize) throws IOException { FileOutputStream zeroFile = new FileOutputStream(path); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(zeroFile, bufferSize); byte[] record = new byte[KEY_HASH_SIZE + VALUE_SIZE]; HankTimer timer = new HankTimer(); for (int i = 0; i < numRecords; ++i) { bufferedOutputStream.write(record); } bufferedOutputStream.close(); zeroFile.close(); double elapsedSecs = timer.getDurationMs() / 1000.0; long totalBytes = numRecords * record.length; System.out.println("Throughput to write zero file of size " + FormatUtils.formatNumBytes(totalBytes) + " with buffer of " + FormatUtils.formatNumBytes(bufferSize) + ": " + FormatUtils.formatDataThroughput(totalBytes / elapsedSecs)); }
public static String formatUpdateProgress(UpdateProgressAggregator updateProgressAggregator, long eta) { if (updateProgressAggregator == null) { return ""; } StringBuilder content = new StringBuilder(); StringBuilder tooltip = new StringBuilder(); UpdateProgress updateProgress = updateProgressAggregator.computeUpdateProgress(); content.append(FormatUtils.formatDouble(updateProgress.getUpdateProgress() * 100) + "% up-to-date" + " (" + updateProgress.getNumPartitionsUpToDate() + "/" + updateProgress.getNumPartitions() + ")"); if (eta >= 0) { content.append(" ETA: " + FormatUtils.formatSecondsDuration(eta)); } content.append("<div class=\'progress-bar\'><div class=\'progress-bar-filler\' style=\'width: " + Math.round(updateProgress.getUpdateProgress() * 100) + "%\'></div></div>"); // Build tooltip tooltip.append("<table>"); for (Map.Entry<Domain, UpdateProgress> entry : updateProgressAggregator.sortedEntrySet()) { UpdateProgress domainUpdateProgress = entry.getValue(); tooltip.append("<tr><td class='centered'>"); tooltip.append(entry.getKey().getName()); tooltip.append("</td><td class='centered'>"); tooltip.append("<div class=\'progress-bar\'><div class=\'progress-bar-filler\' style=\'width: " + Math.round(domainUpdateProgress.getUpdateProgress() * 100) + "%\'></div></div>"); tooltip.append("</td><td class='centered'>"); tooltip.append(FormatUtils.formatDouble(domainUpdateProgress.getUpdateProgress() * 100) + "%"); tooltip.append("</td></tr>"); } tooltip.append("</table>"); return htmlTooltip(content.toString(), "Update Progress", tooltip.toString()); }
public static String formatDataThroughput(double bytesThrougput) { return formatNumBytes(Math.round(bytesThrougput)) + "/s"; }
public static String formatNumBytes(long numBytes) { long kilo = 1 << 10; long mega = kilo << 10; long giga = mega << 10; long tera = giga << 10; long peta = tera << 10; if (numBytes < kilo) { return numBytes + "B"; } else if (numBytes < mega) { return formatDouble((double) numBytes / kilo) + "KB"; } else if (numBytes < giga) { return formatDouble((double) numBytes / mega) + "MB"; } else if (numBytes < tera) { return formatDouble((double) numBytes / giga) + "GB"; } else if (numBytes < peta) { return formatDouble((double) numBytes / tera) + "TB"; } else { return formatDouble((double) numBytes / peta) + "PB"; } }
public static void main(String[] args) throws IOException, InterruptedException { int randomReadBufferSize = Integer.valueOf(args[0]); long totalRandomReads = NUM_RANDOM_READS * NUM_RANDOM_READ_THREADS; File[] testFiles = new File[args.length - NUM_OPTIONS]; for (int i = NUM_OPTIONS; i < args.length; ++i) { testFiles[i - NUM_OPTIONS] = new File(args[i]); LOG.info("Using test file: " + testFiles[i - NUM_OPTIONS].getAbsolutePath()); } Thread[] threads = new Thread[NUM_RANDOM_READ_THREADS]; for (int i = 0; i < NUM_RANDOM_READ_THREADS; ++i) { threads[i] = new Thread(new RandomReadsRunnable(testFiles, randomReadBufferSize)); } LOG.info("Calculating time taken to perform " + totalRandomReads + " random " + FormatUtils.formatNumBytes(randomReadBufferSize) + " reads in " + NUM_RANDOM_READ_THREADS + " threads (" + NUM_RANDOM_READS + " random reads each)"); long startTime = System.currentTimeMillis(); for (Thread thread : threads) { thread.start(); } for (Thread thread : threads) { thread.join(); } long totalDuration = System.currentTimeMillis() - startTime; LOG.info("Total duration: " + totalDuration + " ms"); LOG.info("Total throughput: " + ((double) totalRandomReads / (totalDuration / 1000.0)) + " random reads per second"); LOG.info("Total throughput: " + FormatUtils.formatNumBytes((long) ((totalRandomReads * randomReadBufferSize) / (totalDuration / 1000.0))) + "/s"); }
public static String formatCacheHits(RuntimeStatisticsAggregator runtimeStatisticsAggregator) { double l1 = runtimeStatisticsAggregator.getL1CacheHitRate(); double l2 = runtimeStatisticsAggregator.getL2CacheHitRate(); if (l1 == 0 && l2 == 0) { return "-"; } else { String l1Str = "-"; String l2Str = "-"; if (l1 != 0) { l1Str = FormatUtils.formatDouble(l1 * 100.0) + "%"; } if (l2 != 0) { l2Str = FormatUtils.formatDouble(l2 * 100.0) + "%"; } return l1Str + " / " + l2Str; } }
LOG.info(getLogPrefix() + "Load on connections to " + entry.getKey() + ": " + FormatUtils.formatDouble(connectionLoad.getLoad()) + "% (" + connectionLoad.getNumConnectionsLocked() + "/" + connectionLoad.getNumConnections() + " locked connections)"); double cacheHitRate = (double)numCacheHits / (double)numRequests; LOG.info(getLogPrefix() + "Throughput: " + FormatUtils.formatDouble(throughput) + " queries/s" + ", client-side cache hit rate: " + FormatUtils.formatDouble(cacheHitRate * 100) + "%" + ", cache: " + responseCache.size() + " items totaling " + FormatUtils.formatNumBytes(responseCache.getNumManagedBytes()));
public static void testPerformanceCueballWriter(String localTmpDir) throws IOException { // Fill in all indexable blocks long numRecords = getNumTotalRecords(); Writer writer = getCueball(localTmpDir).getWriter( new MockDomainVersion(0, 0L, new IncrementalDomainVersionProperties.Base()), new LocalPartitionRemoteFileOps(localTmpDir, 0), 0); HankTimer timer = new HankTimer(); for (long i = 0; i < numRecords; ++i) { writer.write(key(i, KEY_SIZE), value(i, VALUE_SIZE)); } writer.close(); double elapsedMs = timer.getDurationMs(); double elapsedSecs = elapsedMs / 1000.0; long totalBytes = numRecords * (KEY_HASH_SIZE + VALUE_SIZE); System.out.println("Test took " + elapsedMs + "ms, wrote " + numRecords + " records totalling " + FormatUtils.formatNumBytes(totalBytes)); System.out.println(String.format("Throughput: %.2f writes/sec", numRecords / elapsedSecs)); System.out.println("Throughput: " + FormatUtils.formatDataThroughput(totalBytes / elapsedSecs)); createZeroFile(localTmpDir + "/zero_file0", numRecords, IOStreamUtils.DEFAULT_BUFFER_SIZE); createZeroFile(localTmpDir + "/zero_file1", numRecords, 10 << 20); }
LOG.info("Update failed and took " + FormatUtils.formatSecondsDuration(timer.getDurationMs() / 1000)); throw e; LOG.info("Update succeeded and took " + FormatUtils.formatSecondsDuration(timer.getDurationMs() / 1000));
+ ": merged Curly deltas in " + FormatUtils.formatSecondsDuration(curlyTimeMs / 1000) + ", ran Cueball update in " + FormatUtils.formatSecondsDuration(cueballTimeMs / 1000));
statistics.getDurationsMs().put("Update execution", executionTimeMs); LOG.info("Update in " + localPartitionRoot + " to " + updatingToVersion + ": fetched data in " + FormatUtils.formatSecondsDuration(fetchTimeMs / 1000) + ", executed in " + FormatUtils.formatSecondsDuration(executionTimeMs / 1000)); } finally { cleanCachedVersions();