HCOLL-231 Add another test to show it works.

This commit is contained in:
Peter Lawrey
2014-12-16 21:52:33 +00:00
parent 961b5d1b38
commit f1a8a939b4
2 changed files with 12 additions and 8 deletions
@@ -553,8 +553,10 @@ public final class ChronicleMapBuilder<K, V> implements Cloneable,
private int estimateSegmentsBasedOnSize() {
// based on entries with multimap of 100 bytes.
int segmentsForEntries = estimateSegmentsForEntries();
return entrySize >= 100000
int segmentsForEntries = estimateSegmentsForEntries(entries);
return entrySize >= 1000000
? segmentsForEntries * 16
: entrySize >= 100000
? segmentsForEntries * 8
: entrySize >= 10000
? segmentsForEntries * 4
@@ -563,8 +565,7 @@ public final class ChronicleMapBuilder<K, V> implements Cloneable,
: segmentsForEntries;
}
private int estimateSegmentsForEntries() {
long size = entries;
private static int estimateSegmentsForEntries(long size) {
if (size > 200 << 20)
return 256;
if (size >= 1 << 20)
@@ -575,6 +576,8 @@ public final class ChronicleMapBuilder<K, V> implements Cloneable,
return 32;
if (size >= 4 << 10)
return 16;
if (size >= 1 << 10)
return 8;
return 1;
}
@@ -103,24 +103,25 @@ public class LargeEntriesTest {
@Ignore("Performance Test")
public void testLargeStringsPerf() throws ExecutionException, InterruptedException, IOException {
doLargeEntryPerf(10000, 100 * 1024);
doLargeEntryPerf(1000000, 1024);
doLargeEntryPerf(100000, 10 * 1024);
doLargeEntryPerf(10000, 100 * 1024);
doLargeEntryPerf(3000, 1024 * 1024);
}
private void doLargeEntryPerf(int ENTRIES, final int ENTRY_SIZE) throws IOException, InterruptedException, ExecutionException {
System.out.printf("Testing %,d entries of %,d KB%n", ENTRIES, ENTRY_SIZE);
System.out.printf("Testing %,d entries of %,d KB%n", ENTRIES, ENTRY_SIZE / 1024);
File file = File.createTempFile("largeEntries", ".deleteme");
file.deleteOnExit();
final ChronicleMap<String, String> map = ChronicleMapBuilder
.of(String.class, String.class)
.valueMarshaller(SnappyStringMarshaller.INSTANCE)
.entries(ENTRIES * 2)
.entrySize(ENTRY_SIZE / 6)
.entries(ENTRIES)
.entrySize(ENTRY_SIZE / 7 + 200)
.putReturnsNull(true)
.createPersistedTo(file);
{
warmUpCompression(ENTRY_SIZE);
// warmUpCompression(ENTRY_SIZE);
int threads = Runtime.getRuntime().availableProcessors();
ExecutorService es = Executors.newFixedThreadPool(threads);
final int block = ENTRIES / threads;