Improve AverageValueSizeTest

This commit is contained in:
leventov
2016-04-05 16:21:35 +01:00
parent 6baf11b5c4
commit 7aedfba7a8
+8 -7
View File
@@ -26,18 +26,19 @@ import java.util.LongSummaryStatistics;
public class AverageValueSizeTest {
public static <V> double averageValueSize(Class<V> valueClass, Iterable<V> values) {
ChronicleMap<Integer, V> testMap = ChronicleMap.of(Integer.class, valueClass)
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());
.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();
}
return statistics.getAverage();
}
@Test