public void addValue(double value) { synchronized (_statistics) { _statistics.addValue(value); } }
public void clear() { synchronized (_statistics) { _statistics.clear(); } } }
public static void main(String[] args) { SummaryStatistics statObject = new SummaryStatistics(); SummaryStatistics statByte = new SummaryStatistics(); for (int i = 0; i < 10; i++) { statByte.addValue(testByte()); statObject.addValue(testObject()); } System.out.println("Time (ms) Object: " + statObject.getMean() + " | " + statObject.getStandardDeviation()); System.out.println("Time (ms) Byte: " + statByte.getMean() + " | " + statByte.getStandardDeviation()); }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * statistics. * @return Current values of statistics */ public StatisticalSummary getSummary() { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); }
protected void printSegmentAssignment(Map<String, Map<String, String>> mapping) throws Exception { LOGGER.info(JsonUtils.objectToPrettyString(mapping)); Map<String, List<String>> serverToSegmentMapping = new TreeMap<>(); for (String segment : mapping.keySet()) { Map<String, String> serverToStateMap = mapping.get(segment); for (String server : serverToStateMap.keySet()) { if (!serverToSegmentMapping.containsKey(server)) { serverToSegmentMapping.put(server, new ArrayList<>()); } serverToSegmentMapping.get(server).add(segment); } } DescriptiveStatistics stats = new DescriptiveStatistics(); for (String server : serverToSegmentMapping.keySet()) { List<String> list = serverToSegmentMapping.get(server); LOGGER.info("server " + server + " has " + list.size() + " segments"); stats.addValue(list.size()); } LOGGER.info("Segment Distrbution stat"); LOGGER.info(stats.toString()); }
public void report() { synchronized (_statistics) { LOGGER.info("--------------------------------------------------------------------------------"); LOGGER.info("{}:", _name); LOGGER.info(_statistics.toString()); LOGGER.info("10th percentile: {}", _statistics.getPercentile(10.0)); LOGGER.info("25th percentile: {}", _statistics.getPercentile(25.0)); LOGGER.info("50th percentile: {}", _statistics.getPercentile(50.0)); LOGGER.info("90th percentile: {}", _statistics.getPercentile(90.0)); LOGGER.info("95th percentile: {}", _statistics.getPercentile(95.0)); LOGGER.info("99th percentile: {}", _statistics.getPercentile(99.0)); LOGGER.info("99.9th percentile: {}", _statistics.getPercentile(99.9)); LOGGER.info("--------------------------------------------------------------------------------"); } }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * aggregate statistics. * * @return Current values of aggregate statistics */ public StatisticalSummary getSummary() { synchronized (statistics) { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); } }
/** * Initializes a new AggregateSummaryStatistics with default statistics * implementations. * */ public AggregateSummaryStatistics() { this(new SummaryStatistics()); }
public StatCollector() { _stats = new SynchronizedDescriptiveStatistics(); _stats.setWindowSize(DEFAULT_WINDOW_SIZE); }
/** * {@inheritDoc}. This version returns a sum of all the aggregated data. * * @see StatisticalSummary#getSum() */ public double getSum() { synchronized (statistics) { return statistics.getSum(); } }
/** * Returns the <a href="http://www.xycoon.com/geometric_mean.htm"> * geometric mean </a> of the available values * @return The geometricMean, Double.NaN if no values have been added, * or if the product of the available values is less than or equal to 0. */ public double getGeometricMean() { return apply(geometricMeanImpl); }
/** * Construct a DescriptiveStatistics instance with the specified window * * @param window the window size. */ public DescriptiveStatistics(int window) { setWindowSize(window); }
public static void main(String[] args) { SummaryStatistics statObject = new SummaryStatistics(); SummaryStatistics statByte = new SummaryStatistics(); for (int i = 0; i < 10; i++) { statByte.addValue(testByte()); statObject.addValue(testObject()); } System.out.println("Time (ms) Object: " + statObject.getMean() + " | " + statObject.getStandardDeviation()); System.out.println("Time (ms) Byte: " + statByte.getMean() + " | " + statByte.getStandardDeviation()); }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * statistics. * * @return Current values of statistics */ public StatisticalSummary getSummary() { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); }
public static void generateReport(String dataFileName) throws IOException { List<DescriptiveStatistics> statisticsList = new ArrayList<>(); String dataString; BufferedReader dataReader = new BufferedReader(new FileReader(dataFileName)); // First line is treated as header String[] columns = dataReader.readLine().split("\\s+"); int numColumns = columns.length; for (int i = 0; i < numColumns; ++i) { statisticsList.add(new DescriptiveStatistics()); } while ((dataString = dataReader.readLine()) != null) { String[] dataArray = dataString.trim().split(" "); if (dataArray.length != numColumns) { throw new RuntimeException( "Row has missing columns: " + Arrays.toString(dataArray) + " Expected: " + numColumns + " columns."); } for (int i = 0; i < dataArray.length; ++i) { double data = Double.valueOf(dataArray[i]); statisticsList.get(i).addValue(data); } } for (int i = 0; i < numColumns; i++) { LOGGER.info("Stats: {}: {}", columns[i], statisticsList.get(i).toString().replace("\n", "\t")); } }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * aggregate statistics. * * @return Current values of aggregate statistics */ public StatisticalSummary getSummary() { synchronized (statistics) { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); } }
/** * Returns the Kurtosis of the available values. Kurtosis is a * measure of the "peakedness" of a distribution * @return The kurtosis, Double.NaN if no values have been added, or 0.0 * for a value set <=3. */ public double getKurtosis() { return apply(kurtosisImpl); }
@Test public void testMemoryLeakage() { long memoryBaseline = 0; SummaryStatistics stats = new SummaryStatistics(); int numRuns = 25; for (int r = 0; r < numRuns; r++) { if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory before run "+(r+1)+": " + memoryBaseline / 1024 + " KB"); } for (int t = 0; t < 1000; t++) { graph.addVertex(); graph.tx().rollback(); TitanTransaction tx = graph.newTransaction(); tx.addVertex(); tx.rollback(); } if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory after run " + (r + 1) + ": " + memoryBaseline / 1024 + " KB"); } clopen(); } System.out.println("Average: " + stats.getMean() + " Std. Dev: " + stats.getStandardDeviation()); assertTrue(stats.getStandardDeviation() < stats.getMin()); }
/** * Return a {@link StatisticalSummaryValues} instance reporting current * statistics. * @return Current values of statistics */ public StatisticalSummary getSummary() { return new StatisticalSummaryValues(getMean(), getVariance(), getN(), getMax(), getMin(), getSum()); }
@Test public void testMemoryLeakage() { long memoryBaseline = 0; SummaryStatistics stats = new SummaryStatistics(); int numRuns = 25; for (int r = 0; r < numRuns; r++) { if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory before run "+(r+1)+": " + memoryBaseline / 1024 + " KB"); } for (int t = 0; t < 1000; t++) { graph.addVertex(); graph.tx().rollback(); JanusGraphTransaction tx = graph.newTransaction(); tx.addVertex(); tx.rollback(); } if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory after run " + (r + 1) + ": " + memoryBaseline / 1024 + " KB"); } clopen(); } System.out.println("Average: " + stats.getMean() + " Std. Dev: " + stats.getStandardDeviation()); assertTrue(stats.getStandardDeviation() < stats.getMin()); }