HCOLL-198 Add a long -> long test.

This commit is contained in:
Peter Lawrey
2014-11-11 00:32:06 +00:00
parent edf2927a06
commit c90f424e3f
4 changed files with 161 additions and 6 deletions
@@ -648,7 +648,7 @@ public class ChronicleMapTest {
InstantiationException, InterruptedException, ExecutionException {
// int runs = Integer.getInteger("runs", 10);
int procs = Runtime.getRuntime().availableProcessors();
int threads = procs * 2; // runs > 100 ? procs / 2 : procs;
int threads = procs * 3; // runs > 100 ? procs / 2 : procs;
ExecutorService es = Executors.newFixedThreadPool(procs);
for (int runs : new int[]{10, 50, 250, 500, 1000, 2500}) {
// JAVA 8 produces more garbage than previous versions for internal work.
@@ -658,6 +658,7 @@ public class ChronicleMapTest {
.of(CharSequence.class, LongValue.class)
.entries(entries)
.entryAndValueAlignment(OF_8_BYTES)
.actualSegments(8 * 1024)
.entrySize(24);
File tmpFile = File.createTempFile("testAcquirePerf", ".deleteme");
@@ -714,6 +715,79 @@ public class ChronicleMapTest {
es.awaitTermination(1, TimeUnit.MINUTES);
}
@Test
@Ignore
public void testAcquireLockedLLPerf()
throws IOException, ClassNotFoundException, IllegalAccessException,
InstantiationException, InterruptedException, ExecutionException {
// int runs = Integer.getInteger("runs", 10);
int procs = Runtime.getRuntime().availableProcessors();
int threads = procs * 3; // runs > 100 ? procs / 2 : procs;
ExecutorService es = Executors.newFixedThreadPool(1);
for (int runs : new int[]{10, 50, 100, 250, 500, 1000, 2500}) {
// JAVA 8 produces more garbage than previous versions for internal work.
// System.gc();
final long entries = runs * 1000 * 1000L;
OffHeapUpdatableChronicleMapBuilder<LongValue, LongValue> builder = OffHeapUpdatableChronicleMapBuilder
.of(LongValue.class, LongValue.class)
.entries(entries)
.entryAndValueAlignment(OF_8_BYTES)
.actualSegments(8 * 1024)
.entrySize(16);
File tmpFile = File.createTempFile("testAcquirePerf", ".deleteme");
tmpFile.deleteOnExit();
final ChronicleMap<LongValue, LongValue> map = builder.createPersistedTo(tmpFile);
int count = runs > 500 ? runs > 1200 ? 3 : 5 : 5;
final int independence = Math.min(procs, runs > 500 ? 8 : 4);
System.out.println("\nKey size: " + runs + " Million entries. " + builder);
for (int j = 0; j < count; j++) {
long start = System.currentTimeMillis();
List<Future> futures = new ArrayList<Future>();
for (int i = 0; i < threads; i++) {
final int t = i;
futures.add(es.submit(new Runnable() {
@Override
public void run() {
LongValue key = DataValueClasses.newDirectInstance(LongValue.class);
LongValue value = nativeLongValue();
StringBuilder sb = new StringBuilder();
long next = 50 * 1000 * 1000;
// use a factor to give up to 10 digit numbers.
int factor = Math.max(1, (int) ((10 * 1000 * 1000 * 1000L - 1) / entries));
for (long j = t % independence; j < entries + independence - 1; j += independence) {
key.setValue(j * factor);
long n;
try (WriteContext wc = map.acquireUsingLocked(key, value)) {
n = value.addValue(1);
}
assert n > 0 && n < 1000 : "Counter corrupted " + n;
if (t == 0 && j >= next) {
long size = map.longSize();
if (size < 0) throw new AssertionError("size: " + size);
System.out.println(j + ", size: " + size);
next += 50 * 1000 * 1000;
}
}
}
}));
}
for (Future future : futures) {
future.get();
}
long time = System.currentTimeMillis() - start;
System.out.printf("Throughput %.1f M ops/sec%n", threads * entries / independence / 1000.0 / time);
}
printStatus();
File file = map.file();
map.close();
file.delete();
}
es.shutdown();
es.awaitTermination(1, TimeUnit.MINUTES);
}
@Test
@Ignore
public void testCHMAcquirePerf() throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InterruptedException {