Java Code Examples for java.util.LongSummaryStatistics#getAverage()
The following examples show how to use
java.util.LongSummaryStatistics#getAverage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AverageValueSizeTest.java From Chronicle-Map with Apache License 2.0 | 5 votes |
public static <V> double averageValueSize(Class<V> valueClass, Iterable<V> values) { try (ChronicleMap<Integer, V> testMap = ChronicleMap.of(Integer.class, valueClass) // doesn't matter, anyway not a single value will be written to a map .averageValueSize(1) .entries(1) .create()) { LongSummaryStatistics statistics = new LongSummaryStatistics(); for (V value : values) { try (MapSegmentContext<Integer, V, ?> c = testMap.segmentContext(0)) { statistics.accept(c.wrapValueAsData(value).size()); } } return statistics.getAverage(); } }
Example 2
Source File: LongSummary.java From jenetics with Apache License 2.0 | 5 votes |
/** * Return a new value object of the statistical summary, currently * represented by the {@code statistics} object. * * @param statistics the creating (mutable) statistics class * @return the statistical moments */ public static LongSummary of(final LongSummaryStatistics statistics) { return new LongSummary( statistics.getCount(), statistics.getMin(), statistics.getMax(), statistics.getSum(), statistics.getAverage() ); }
Example 3
Source File: ReplicationMetrics.java From ambry with Apache License 2.0 | 5 votes |
/** * Get tha average replication lag of remote replicas in given datacenter * @param dcName the name of dc where remote replicas sit * @return the average replication lag */ double getAvgLagFromDc(String dcName) { Set<RemoteReplicaInfo> replicaInfos = remoteReplicaInfosByDc.get(dcName); if (replicaInfos == null || replicaInfos.isEmpty()) { return -1.0; } LongSummaryStatistics longSummaryStatistics = replicaInfos.stream().collect(Collectors.summarizingLong(RemoteReplicaInfo::getRemoteLagFromLocalInBytes)); dcToReplicaLagStats.put(dcName, longSummaryStatistics); return longSummaryStatistics.getAverage(); }